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

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

Issue 573943004: Use allocation throughput to estimate next scavenge event in idle notification. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/heap/gc-idle-time-handler.cc ('k') | src/heap/heap.cc » ('j') | 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 13 matching lines...) Expand all
24 result.contexts_disposed = 0; 24 result.contexts_disposed = 0;
25 result.size_of_objects = kSizeOfObjects; 25 result.size_of_objects = kSizeOfObjects;
26 result.incremental_marking_stopped = false; 26 result.incremental_marking_stopped = false;
27 result.can_start_incremental_marking = true; 27 result.can_start_incremental_marking = true;
28 result.sweeping_in_progress = false; 28 result.sweeping_in_progress = false;
29 result.mark_compact_speed_in_bytes_per_ms = kMarkCompactSpeed; 29 result.mark_compact_speed_in_bytes_per_ms = kMarkCompactSpeed;
30 result.incremental_marking_speed_in_bytes_per_ms = kMarkingSpeed; 30 result.incremental_marking_speed_in_bytes_per_ms = kMarkingSpeed;
31 result.scavenge_speed_in_bytes_per_ms = kScavengeSpeed; 31 result.scavenge_speed_in_bytes_per_ms = kScavengeSpeed;
32 result.available_new_space_memory = kNewSpaceCapacity; 32 result.available_new_space_memory = kNewSpaceCapacity;
33 result.new_space_capacity = kNewSpaceCapacity; 33 result.new_space_capacity = kNewSpaceCapacity;
34 result.new_space_allocation_throughput_in_bytes_per_ms =
35 kNewSpaceAllocationThroughput;
34 return result; 36 return result;
35 } 37 }
36 38
37 static const size_t kSizeOfObjects = 100 * MB; 39 static const size_t kSizeOfObjects = 100 * MB;
38 static const size_t kMarkCompactSpeed = 200 * KB; 40 static const size_t kMarkCompactSpeed = 200 * KB;
39 static const size_t kMarkingSpeed = 200 * KB; 41 static const size_t kMarkingSpeed = 200 * KB;
40 static const size_t kScavengeSpeed = 100 * KB; 42 static const size_t kScavengeSpeed = 100 * KB;
41 static const size_t kNewSpaceCapacity = 1 * MB; 43 static const size_t kNewSpaceCapacity = 1 * MB;
44 static const size_t kNewSpaceAllocationThroughput = 10 * KB;
42 45
43 private: 46 private:
44 GCIdleTimeHandler handler_; 47 GCIdleTimeHandler handler_;
45 }; 48 };
46 49
47 } // namespace 50 } // namespace
48 51
49 52
50 TEST(GCIdleTimeHandler, EstimateMarkingStepSizeInitial) { 53 TEST(GCIdleTimeHandler, EstimateMarkingStepSizeInitial) {
51 size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(1, 0); 54 size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(1, 0);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 117
115 118
116 TEST(GCIdleTimeHandler, EstimateScavengeTimeNonZero) { 119 TEST(GCIdleTimeHandler, EstimateScavengeTimeNonZero) {
117 size_t size = 1 * MB; 120 size_t size = 1 * MB;
118 size_t speed = 1 * MB; 121 size_t speed = 1 * MB;
119 size_t time = GCIdleTimeHandler::EstimateScavengeTime(size, speed); 122 size_t time = GCIdleTimeHandler::EstimateScavengeTime(size, speed);
120 EXPECT_EQ(size / speed, time); 123 EXPECT_EQ(size / speed, time);
121 } 124 }
122 125
123 126
127 TEST(GCIdleTimeHandler, ScavangeMayHappenSoonInitial) {
128 size_t available = 100 * KB;
129 EXPECT_FALSE(GCIdleTimeHandler::ScavangeMayHappenSoon(available, 0));
130 }
131
132
133 TEST(GCIdleTimeHandler, ScavangeMayHappenSoonNonZeroFalse) {
134 size_t available = (GCIdleTimeHandler::kMaxFrameRenderingIdleTime + 1) * KB;
135 size_t speed = 1 * KB;
136 EXPECT_FALSE(GCIdleTimeHandler::ScavangeMayHappenSoon(available, speed));
137 }
138
139
140 TEST(GCIdleTimeHandler, ScavangeMayHappenSoonNonZeroTrue) {
141 size_t available = GCIdleTimeHandler::kMaxFrameRenderingIdleTime * KB;
142 size_t speed = 1 * KB;
143 EXPECT_TRUE(GCIdleTimeHandler::ScavangeMayHappenSoon(available, speed));
144 }
145
146
124 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeLargeIdleTime) { 147 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeLargeIdleTime) {
125 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); 148 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
126 heap_state.contexts_disposed = 1; 149 heap_state.contexts_disposed = 1;
127 heap_state.incremental_marking_stopped = true; 150 heap_state.incremental_marking_stopped = true;
128 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; 151 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms;
129 int idle_time_ms = 152 int idle_time_ms =
130 static_cast<int>((heap_state.size_of_objects + speed - 1) / speed); 153 static_cast<int>((heap_state.size_of_objects + speed - 1) / speed);
131 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); 154 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
132 EXPECT_EQ(DO_FULL_GC, action.type); 155 EXPECT_EQ(DO_FULL_GC, action.type);
133 } 156 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 EXPECT_EQ(DONE, action.type); 283 EXPECT_EQ(DONE, action.type);
261 // Emulate mutator work. 284 // Emulate mutator work.
262 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { 285 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) {
263 handler()->NotifyScavenge(); 286 handler()->NotifyScavenge();
264 } 287 }
265 heap_state.can_start_incremental_marking = true; 288 heap_state.can_start_incremental_marking = true;
266 action = handler()->Compute(idle_time_ms, heap_state); 289 action = handler()->Compute(idle_time_ms, heap_state);
267 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); 290 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type);
268 } 291 }
269 292
293
294 TEST_F(GCIdleTimeHandlerTest, Scavenge) {
295 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
296 int idle_time_ms = 10;
297 heap_state.available_new_space_memory =
298 kNewSpaceAllocationThroughput * idle_time_ms;
299 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
300 EXPECT_EQ(DO_SCAVENGE, action.type);
301 }
302
303
304 TEST_F(GCIdleTimeHandlerTest, ScavengeAndDone) {
305 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
306 int idle_time_ms = 10;
307 heap_state.can_start_incremental_marking = false;
308 heap_state.incremental_marking_stopped = true;
309 heap_state.available_new_space_memory =
310 kNewSpaceAllocationThroughput * idle_time_ms;
311 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
312 EXPECT_EQ(DO_SCAVENGE, action.type);
313 heap_state.available_new_space_memory = kNewSpaceCapacity;
314 action = handler()->Compute(idle_time_ms, heap_state);
315 EXPECT_EQ(DO_NOTHING, action.type);
316 }
317
270 } // namespace internal 318 } // namespace internal
271 } // namespace v8 319 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/gc-idle-time-handler.cc ('k') | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698