Reviewers: ulan,

Description:
Avoid idle times smaller than 1ms.

BUG=

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

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

Affected files (+33, -0 lines):
  M src/heap/gc-idle-time-handler.cc
  M src/heap/gc-idle-time-handler-unittest.cc


Index: src/heap/gc-idle-time-handler-unittest.cc
diff --git a/src/heap/gc-idle-time-handler-unittest.cc b/src/heap/gc-idle-time-handler-unittest.cc index 195a88dcc1fe79630b4ffae6ea67607479b57563..b4f2f74f57b245b96f7e4f28908664ab3e012a50 100644
--- a/src/heap/gc-idle-time-handler-unittest.cc
+++ b/src/heap/gc-idle-time-handler-unittest.cc
@@ -315,5 +315,34 @@ TEST_F(GCIdleTimeHandlerTest, ScavengeAndDone) {
   EXPECT_EQ(DO_NOTHING, action.type);
 }

+
+TEST_F(GCIdleTimeHandlerTest, ZeroIdleTimeNothingToDo) {
+  GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
+  int idle_time_ms = 0;
+  GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
+  EXPECT_EQ(DO_NOTHING, action.type);
+}
+
+
+TEST_F(GCIdleTimeHandlerTest, ZeroIdleTimeDoNothingButStartIdleRound) {
+  GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
+  int idle_time_ms = 10;
+ for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) {
+    GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
+    if (action.type == DONE) break;
+    EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type);
+ // In this case we try to emulate incremental marking steps the finish with
+    // a full gc.
+    handler()->NotifyIdleMarkCompact();
+  }
+  GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
+  // Emulate mutator work.
+  for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) {
+    handler()->NotifyScavenge();
+  }
+  action = handler()->Compute(0, heap_state);
+  EXPECT_EQ(DO_NOTHING, action.type);
+}
+
 }  // namespace internal
 }  // namespace v8
Index: src/heap/gc-idle-time-handler.cc
diff --git a/src/heap/gc-idle-time-handler.cc b/src/heap/gc-idle-time-handler.cc index 8cce929b399d41a564a7d4a65d12504565198a1c..7c74dcb3dac79d1068e2f26ca3ed7716a5227cdc 100644
--- a/src/heap/gc-idle-time-handler.cc
+++ b/src/heap/gc-idle-time-handler.cc
@@ -126,6 +126,10 @@ GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms,
     }
   }

+  if (idle_time_in_ms == 0) {
+    return GCIdleTimeAction::Nothing();
+  }
+
   if (heap_state.incremental_marking_stopped) {
     size_t estimated_time_in_ms =
         EstimateMarkCompactTime(heap_state.size_of_objects,


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