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

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

Issue 1024043003: Simplified garbage collection idle handler. (Closed) 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
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | test/cctest/test-api.cc » ('J')
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 "src/heap/gc-idle-time-handler.h" 5 #include "src/heap/gc-idle-time-handler.h"
6 #include "src/heap/gc-tracer.h" 6 #include "src/heap/gc-tracer.h"
7 #include "src/utils.h" 7 #include "src/utils.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
11 11
12 const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9; 12 const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9;
13 const size_t GCIdleTimeHandler::kMaxMarkCompactTimeInMs = 1000; 13 const size_t GCIdleTimeHandler::kMaxMarkCompactTimeInMs = 1000;
14 const size_t GCIdleTimeHandler::kMaxFinalIncrementalMarkCompactTimeInMs = 1000; 14 const size_t GCIdleTimeHandler::kMaxFinalIncrementalMarkCompactTimeInMs = 1000;
15 const size_t GCIdleTimeHandler::kMinTimeForFinalizeSweeping = 100; 15 const size_t GCIdleTimeHandler::kMinTimeForFinalizeSweeping = 100;
16 const int GCIdleTimeHandler::kMaxMarkCompactsInIdleRound = 7; 16 const int GCIdleTimeHandler::kMaxMarkCompactsInIdleRound = 2;
17 const int GCIdleTimeHandler::kIdleScavengeThreshold = 5; 17 const int GCIdleTimeHandler::kIdleScavengeThreshold = 5;
18 const double GCIdleTimeHandler::kHighContextDisposalRate = 100; 18 const double GCIdleTimeHandler::kHighContextDisposalRate = 100;
19 const size_t GCIdleTimeHandler::kMinTimeForOverApproximatingWeakClosureInMs = 1; 19 const size_t GCIdleTimeHandler::kMinTimeForOverApproximatingWeakClosureInMs = 1;
20 20
21 21
22 void GCIdleTimeAction::Print() { 22 void GCIdleTimeAction::Print() {
23 switch (type) { 23 switch (type) {
24 case DONE: 24 case DONE:
25 PrintF("done"); 25 PrintF("done");
26 break; 26 break;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 217 }
218 218
219 if (ShouldDoScavenge( 219 if (ShouldDoScavenge(
220 static_cast<size_t>(idle_time_in_ms), heap_state.new_space_capacity, 220 static_cast<size_t>(idle_time_in_ms), heap_state.new_space_capacity,
221 heap_state.used_new_space_size, 221 heap_state.used_new_space_size,
222 heap_state.scavenge_speed_in_bytes_per_ms, 222 heap_state.scavenge_speed_in_bytes_per_ms,
223 heap_state.new_space_allocation_throughput_in_bytes_per_ms)) { 223 heap_state.new_space_allocation_throughput_in_bytes_per_ms)) {
224 return GCIdleTimeAction::Scavenge(); 224 return GCIdleTimeAction::Scavenge();
225 } 225 }
226 226
227 if (IsMarkCompactIdleRoundFinished()) { 227 if (IsMarkCompactIdleRoundFinished()) {
Hannes Payer (out of office) 2015/03/23 10:55:25 I am still not happy about the idle round concept.
228 if (EnoughGarbageSinceLastIdleRound()) { 228 if (EnoughGarbageSinceLastIdleRound()) {
229 StartIdleRound(); 229 StartIdleRound();
230 } else { 230 } else {
231 return GCIdleTimeAction::Done(); 231 return GCIdleTimeAction::Done();
232 } 232 }
233 } 233 }
234 234
235 if (heap_state.incremental_marking_stopped) { 235 if (heap_state.incremental_marking_stopped) {
236 if (ShouldDoMarkCompact(static_cast<size_t>(idle_time_in_ms), 236 if (ShouldDoMarkCompact(static_cast<size_t>(idle_time_in_ms),
237 heap_state.size_of_objects, 237 heap_state.size_of_objects,
238 heap_state.mark_compact_speed_in_bytes_per_ms)) { 238 heap_state.mark_compact_speed_in_bytes_per_ms)) {
239 // If there are no more than two GCs left in this idle round and we are 239 return GCIdleTimeAction::FullGC();
240 // allowed to do a full GC, then make those GCs full in order to compact
241 // the code space.
242 // TODO(ulan): Once we enable code compaction for incremental marking, we
243 // can get rid of this special case and always start incremental marking.
244 int remaining_mark_sweeps =
245 kMaxMarkCompactsInIdleRound - mark_compacts_since_idle_round_started_;
246 if (static_cast<size_t>(idle_time_in_ms) > kMaxScheduledIdleTime &&
247 (remaining_mark_sweeps <= 2 ||
248 !heap_state.can_start_incremental_marking)) {
249 return GCIdleTimeAction::FullGC();
250 }
251 }
252 if (!heap_state.can_start_incremental_marking) {
253 return GCIdleTimeAction::Nothing();
254 } 240 }
255 } 241 }
242
256 // TODO(hpayer): Estimate finalize sweeping time. 243 // TODO(hpayer): Estimate finalize sweeping time.
257 if (heap_state.sweeping_in_progress && 244 if (heap_state.sweeping_in_progress &&
258 static_cast<size_t>(idle_time_in_ms) >= kMinTimeForFinalizeSweeping) { 245 static_cast<size_t>(idle_time_in_ms) >= kMinTimeForFinalizeSweeping) {
259 return GCIdleTimeAction::FinalizeSweeping(); 246 return GCIdleTimeAction::FinalizeSweeping();
260 } 247 }
261 248
262 if (heap_state.incremental_marking_stopped && 249 if (heap_state.incremental_marking_stopped &&
263 !heap_state.can_start_incremental_marking) { 250 !heap_state.can_start_incremental_marking) {
264 return GCIdleTimeAction::Nothing(); 251 return GCIdleTimeAction::Nothing();
265 } 252 }
266 size_t step_size = EstimateMarkingStepSize( 253 size_t step_size = EstimateMarkingStepSize(
267 static_cast<size_t>(kIncrementalMarkingStepTimeInMs), 254 static_cast<size_t>(kIncrementalMarkingStepTimeInMs),
268 heap_state.incremental_marking_speed_in_bytes_per_ms); 255 heap_state.incremental_marking_speed_in_bytes_per_ms);
269 return GCIdleTimeAction::IncrementalMarking(step_size); 256 return GCIdleTimeAction::IncrementalMarking(step_size);
270 } 257 }
271 } 258 }
272 } 259 }
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698