Reviewers: jochen (slow - soon OOO), ernstm, ulan,

Description:
Use actual incremental marking throughput in IdleNotification to estimate
marking step size.


BUG=

Please review this at https://codereview.chromium.org/465473002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+16, -19 lines):
  M src/heap/heap.h
  M src/heap/heap.cc


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) *
+       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();
   }
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index c313333362ff7acfa2b3ff6ef519d800276dbeed..55978c1d775f7b70e98273a8126456607448400d 100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -1068,7 +1068,7 @@ class Heap {
   void DisableInlineAllocation();

   // Implements the corresponding V8 API function.
-  bool IdleNotification(int hint);
+  bool IdleNotification(int idle_time_in_ms);

   // Declare all the root indices.  This defines the root list order.
   enum RootListIndex {


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to