Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: test/unittests/heap/gc-idle-time-handler-unittest.cc

Issue 1023153002: Limit rate of full garbage collections triggered by idle notification. Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/heap/gc-idle-time-handler.cc ('K') | « src/heap/mark-compact.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits> 5 #include <limits>
6 6
7 #include "src/heap/gc-idle-time-handler.h" 7 #include "src/heap/gc-idle-time-handler.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 16 matching lines...) Expand all
27 result.incremental_marking_stopped = false; 27 result.incremental_marking_stopped = false;
28 result.can_start_incremental_marking = true; 28 result.can_start_incremental_marking = true;
29 result.sweeping_in_progress = false; 29 result.sweeping_in_progress = false;
30 result.mark_compact_speed_in_bytes_per_ms = kMarkCompactSpeed; 30 result.mark_compact_speed_in_bytes_per_ms = kMarkCompactSpeed;
31 result.incremental_marking_speed_in_bytes_per_ms = kMarkingSpeed; 31 result.incremental_marking_speed_in_bytes_per_ms = kMarkingSpeed;
32 result.scavenge_speed_in_bytes_per_ms = kScavengeSpeed; 32 result.scavenge_speed_in_bytes_per_ms = kScavengeSpeed;
33 result.used_new_space_size = 0; 33 result.used_new_space_size = 0;
34 result.new_space_capacity = kNewSpaceCapacity; 34 result.new_space_capacity = kNewSpaceCapacity;
35 result.new_space_allocation_throughput_in_bytes_per_ms = 35 result.new_space_allocation_throughput_in_bytes_per_ms =
36 kNewSpaceAllocationThroughput; 36 kNewSpaceAllocationThroughput;
37 result.last_mark_compact_time = 0;
38 result.current_time =
39 GCIdleTimeHandler::kMinMillisecondsInBetweenMarkCompact;
37 return result; 40 return result;
38 } 41 }
39 42
40 static const size_t kSizeOfObjects = 100 * MB; 43 static const size_t kSizeOfObjects = 100 * MB;
41 static const size_t kMarkCompactSpeed = 200 * KB; 44 static const size_t kMarkCompactSpeed = 200 * KB;
42 static const size_t kMarkingSpeed = 200 * KB; 45 static const size_t kMarkingSpeed = 200 * KB;
43 static const size_t kScavengeSpeed = 100 * KB; 46 static const size_t kScavengeSpeed = 100 * KB;
44 static const size_t kNewSpaceCapacity = 1 * MB; 47 static const size_t kNewSpaceCapacity = 1 * MB;
45 static const size_t kNewSpaceAllocationThroughput = 10 * KB; 48 static const size_t kNewSpaceAllocationThroughput = 10 * KB;
46 49
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 int idle_time_in_ms = 16; 165 int idle_time_in_ms = 16;
163 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoScavenge( 166 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoScavenge(
164 idle_time_in_ms, heap_state.new_space_capacity, 167 idle_time_in_ms, heap_state.new_space_capacity,
165 heap_state.used_new_space_size, heap_state.scavenge_speed_in_bytes_per_ms, 168 heap_state.used_new_space_size, heap_state.scavenge_speed_in_bytes_per_ms,
166 heap_state.new_space_allocation_throughput_in_bytes_per_ms)); 169 heap_state.new_space_allocation_throughput_in_bytes_per_ms));
167 } 170 }
168 171
169 172
170 TEST_F(GCIdleTimeHandlerTest, ShouldDoMarkCompact) { 173 TEST_F(GCIdleTimeHandlerTest, ShouldDoMarkCompact) {
171 size_t idle_time_in_ms = 16; 174 size_t idle_time_in_ms = 16;
172 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoMarkCompact(idle_time_in_ms, 0, 0)); 175 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoMarkCompact(
176 idle_time_in_ms, 0, 0, 0,
177 GCIdleTimeHandler::kMinMillisecondsInBetweenMarkCompact));
173 } 178 }
174 179
175 180
176 TEST_F(GCIdleTimeHandlerTest, DontDoMarkCompact) { 181 TEST_F(GCIdleTimeHandlerTest, DontDoMarkCompact) {
177 size_t idle_time_in_ms = 1; 182 size_t idle_time_in_ms = 1;
178 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoMarkCompact( 183 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoMarkCompact(
179 idle_time_in_ms, kSizeOfObjects, kMarkingSpeed)); 184 idle_time_in_ms, kSizeOfObjects, kMarkingSpeed, 0,
185 GCIdleTimeHandler::kMinMillisecondsInBetweenMarkCompact));
180 } 186 }
181 187
182 188
189 TEST_F(GCIdleTimeHandlerTest, DontDoMarkCompactRate) {
190 size_t idle_time_in_ms = 16;
191 EXPECT_FALSE(
192 GCIdleTimeHandler::ShouldDoMarkCompact(idle_time_in_ms, 0, 0, 0, 0));
193 }
194
195
183 TEST_F(GCIdleTimeHandlerTest, ShouldDoFinalIncrementalMarkCompact) { 196 TEST_F(GCIdleTimeHandlerTest, ShouldDoFinalIncrementalMarkCompact) {
184 size_t idle_time_in_ms = 16; 197 size_t idle_time_in_ms = 16;
185 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact( 198 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact(
186 idle_time_in_ms, 0, 0)); 199 idle_time_in_ms, 0, 0));
187 } 200 }
188 201
189 202
190 TEST_F(GCIdleTimeHandlerTest, DontDoFinalIncrementalMarkCompact) { 203 TEST_F(GCIdleTimeHandlerTest, DontDoFinalIncrementalMarkCompact) {
191 size_t idle_time_in_ms = 1; 204 size_t idle_time_in_ms = 1;
192 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact( 205 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact(
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 // Emulate mutator work. 448 // Emulate mutator work.
436 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { 449 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) {
437 handler()->NotifyScavenge(); 450 handler()->NotifyScavenge();
438 } 451 }
439 action = handler()->Compute(0, heap_state); 452 action = handler()->Compute(0, heap_state);
440 EXPECT_EQ(DO_NOTHING, action.type); 453 EXPECT_EQ(DO_NOTHING, action.type);
441 } 454 }
442 455
443 } // namespace internal 456 } // namespace internal
444 } // namespace v8 457 } // namespace v8
OLDNEW
« src/heap/gc-idle-time-handler.cc ('K') | « src/heap/mark-compact.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698