Index: src/heap/heap.cc |
diff --git a/src/heap/heap.cc b/src/heap/heap.cc |
index fa941814d1cba540909219a8fc8adfd7ffc1ecca..63d6b66320fbca712d63327480f17837989c963b 100644 |
--- a/src/heap/heap.cc |
+++ b/src/heap/heap.cc |
@@ -4282,30 +4282,28 @@ void Heap::AdvanceIdleIncrementalMarking(intptr_t step_size) { |
} |
-bool Heap::IdleNotification(int hint) { |
+bool Heap::IdleNotification(int idle_time_in_ms) { |
// If incremental marking is off, we do not perform idle notification. |
if (!FLAG_incremental_marking) return true; |
- // Hints greater than this value indicate that |
- // the embedder is requesting a lot of GC work. |
- const int kMaxHint = 1000; |
- const int kMinHintForIncrementalMarking = 10; |
// Minimal hint that allows to do full GC. |
const int kMinHintForFullGC = 100; |
- intptr_t size_factor = Min(Max(hint, 20), kMaxHint) / 4; |
- // The size factor is in range [5..250]. The numbers here are chosen from |
- // experiments. If you changes them, make sure to test with |
- // chrome/performance_ui_tests --gtest_filter="GeneralMixMemoryTest.* |
- intptr_t step_size = size_factor * IncrementalMarking::kAllocatedThreshold; |
- |
- isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample(hint); |
+ // We have to make sure that we finish the IdleNotification before |
+ // idle_time_in_ms. Hence, we conservatively prune our workload estimate. |
+ const int kConservativeTimeRatio = 90; |
+ intptr_t step_size = |
+ ((tracer_.IncrementalMarkingSpeedInBytesPerMillisecond() / 100) * |
jochen (gone - plz use gerrit)
2014/08/12 08:35:24
why not just * 0.9 - that might be safer wrt integ
Hannes Payer (out of office)
2014/08/12 09:48:56
I usually prefer integers, but I changed it to dou
|
+ kConservativeTimeRatio) * |
+ idle_time_in_ms; |
+ isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( |
+ idle_time_in_ms); |
HistogramTimerScope idle_notification_scope( |
isolate_->counters()->gc_idle_notification()); |
if (contexts_disposed_ > 0) { |
contexts_disposed_ = 0; |
int mark_sweep_time = Min(TimeMarkSweepWouldTakeInMs(), 1000); |
- if (hint >= mark_sweep_time && !FLAG_expose_gc && |
+ if (idle_time_in_ms >= mark_sweep_time && !FLAG_expose_gc && |
incremental_marking()->IsStopped()) { |
HistogramTimerScope scope(isolate_->counters()->gc_context()); |
CollectAllGarbage(kReduceMemoryFootprintMask, |
@@ -4346,16 +4344,15 @@ bool Heap::IdleNotification(int hint) { |
// the code space. |
// TODO(ulan): Once we enable code compaction for incremental marking, |
// we can get rid of this special case and always start incremental marking. |
- if (remaining_mark_sweeps <= 2 && hint >= kMinHintForFullGC) { |
+ if (remaining_mark_sweeps <= 2 && idle_time_in_ms >= kMinHintForFullGC) { |
CollectAllGarbage(kReduceMemoryFootprintMask, |
"idle notification: finalize idle round"); |
mark_sweeps_since_idle_round_started_++; |
- } else if (hint > kMinHintForIncrementalMarking) { |
+ } else { |
incremental_marking()->Start(); |
} |
} |
- if (!incremental_marking()->IsStopped() && |
- hint > kMinHintForIncrementalMarking) { |
+ if (!incremental_marking()->IsStopped()) { |
AdvanceIdleIncrementalMarking(step_size); |
} |
@@ -4366,7 +4363,7 @@ bool Heap::IdleNotification(int hint) { |
// If the IdleNotifcation is called with a large hint we will wait for |
// the sweepter threads here. |
- if (hint >= kMinHintForFullGC && |
+ if (idle_time_in_ms >= kMinHintForFullGC && |
mark_compact_collector()->sweeping_in_progress()) { |
mark_compact_collector()->EnsureSweepingCompleted(); |
} |