Reviewers: Hannes Payer,

Message:
PTAL

Description:
Start incremental marking in long idle notification for background tab
disregarding the allocation throughput.

BUG=chromium:506132
LOG=NO

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

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+27, -6 lines):
  M src/heap/heap.cc
  M src/heap/memory-reducer.h
  M src/heap/memory-reducer.cc


Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 3a3de34b408911dee3a445cd40eb28ec8e220e2a..7bc15ce2fdae7e79a8e81f31383d2cf520af5757 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -4968,6 +4968,10 @@ bool Heap::IdleNotification(double deadline_in_seconds) {
   double start_ms = MonotonicallyIncreasingTimeInMs();
   double idle_time_in_ms = deadline_in_ms - start_ms;

+  if (idle_time_in_ms > GCIdleTimeHandler::kMinBackgroundIdleTime) {
+    memory_reducer_.TryStartIdleIncrementalMarking();
+  }
+
   tracer()->SampleAllocation(start_ms, NewSpaceAllocationCounter(),
                              OldGenerationAllocationCounter());

Index: src/heap/memory-reducer.cc
diff --git a/src/heap/memory-reducer.cc b/src/heap/memory-reducer.cc
index ed805f1c0fb23558cb40b7a174bbcc1dad572898..2164e1a4e5c584cfea4d5c68842fcbcc7836e636 100644
--- a/src/heap/memory-reducer.cc
+++ b/src/heap/memory-reducer.cc
@@ -141,5 +141,16 @@ void MemoryReducer::ScheduleTimer(double delay_ms) {
       (delay_ms + kSlackMs) / 1000.0);
 }

+
+void MemoryReducer::TryStartIdleIncrementalMarking() {
+  if (state_.action == kWait && state_.started_gcs < kMaxNumberOfGCs &&
+ FLAG_incremental_marking && heap()->incremental_marking()->IsStopped() &&
+      heap()->incremental_marking()->CanBeActivated()) {
+    heap()->StartIdleIncrementalMarking();
+    ++state_.started_gcs;
+  }
+}
+
+
 }  // internal
 }  // v8
Index: src/heap/memory-reducer.h
diff --git a/src/heap/memory-reducer.h b/src/heap/memory-reducer.h
index 9b0bd16c0b35ae90136a38272ad65fea33cfffdc..39e9df9df230b18dd8cebc398c95e9b7a83e1bac 100644
--- a/src/heap/memory-reducer.h
+++ b/src/heap/memory-reducer.h
@@ -48,6 +48,10 @@ class Heap;
 //     - in the timer callback if the mutator allocation rate is high or
 //       incremental GC is in progress.
 //
+// WAIT n x -> WAIT (n+1) happens:
+//     - if n < kMaxNumberOfGCs and IdleNotification with long delay
+//       called TryStartIdleIncrementalMarking.
+//
 // WAIT n x -> RUN (n+1) happens:
 //     - in the timer callback if (the mutator allocation rate is low or
 //       the heap fragmentation is high) and now_ms >= x and
@@ -78,12 +82,7 @@ class MemoryReducer {
     double next_gc_start_ms;
   };

-  enum EventType {
-    kTimer,
-    kMarkCompact,
-    kScavenge,
-    kContextDisposed,
-  };
+  enum EventType { kTimer, kMarkCompact, kScavenge, kContextDisposed };

   struct Event {
     EventType type;
@@ -105,6 +104,13 @@ class MemoryReducer {
   static State Step(const State& state, const Event& event);
   // Posts a timer task that will call NotifyTimer after the given delay.
   void ScheduleTimer(double delay_ms);
+ // Starts incremental marking in the WAIT state if the number of started GCs
+  // is less than kMaxNumberOfGCs.
+ // This function is called from IdleNotification when it gets long idle delay + // signaling that we can ignore mutator allocation throughput and start GC
+  // right away.
+  // Returns true iff incremental marking was started.
+  void TryStartIdleIncrementalMarking();

   static const int kLongDelayMs;
   static const int kShortDelayMs;


--
--
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