Revision: 24044
Author:   [email protected]
Date:     Thu Sep 18 13:37:36 2014 UTC
Log:      Avoid idle times smaller than 1ms.

BUG=
[email protected]

Review URL: https://codereview.chromium.org/580083002
https://code.google.com/p/v8/source/detail?r=24044

Modified:
 /branches/bleeding_edge/src/heap/gc-idle-time-handler-unittest.cc
 /branches/bleeding_edge/src/heap/gc-idle-time-handler.cc

=======================================
--- /branches/bleeding_edge/src/heap/gc-idle-time-handler-unittest.cc Thu Sep 18 08:44:46 2014 UTC +++ /branches/bleeding_edge/src/heap/gc-idle-time-handler-unittest.cc Thu Sep 18 13:37:36 2014 UTC
@@ -314,6 +314,35 @@
   action = handler()->Compute(idle_time_ms, heap_state);
   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
=======================================
--- /branches/bleeding_edge/src/heap/gc-idle-time-handler.cc Thu Sep 18 08:44:46 2014 UTC +++ /branches/bleeding_edge/src/heap/gc-idle-time-handler.cc Thu Sep 18 13:37:36 2014 UTC
@@ -125,6 +125,10 @@
       return GCIdleTimeAction::Done();
     }
   }
+
+  if (idle_time_in_ms == 0) {
+    return GCIdleTimeAction::Nothing();
+  }

   if (heap_state.incremental_marking_stopped) {
     size_t estimated_time_in_ms =

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