Reviewers: ulan,

Description:
When allocation rate is low and we are close to the new space limit, we should
perform a scavenge during idle time.

BUG=chromium:517395
LOG=n

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

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

Affected files (+25, -4 lines):
  M src/heap/gc-idle-time-handler.h
  M src/heap/gc-idle-time-handler.cc
  M test/unittests/heap/gc-idle-time-handler-unittest.cc


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 f76c48bf9e3ed615ac7f04af25bda87b92014eb0..e9324de4672738681e5119aad59266081f101102 100644
--- a/src/heap/gc-idle-time-handler.cc
+++ b/src/heap/gc-idle-time-handler.cc
@@ -129,10 +129,7 @@ bool GCIdleTimeHandler::ShouldDoScavenge(

   // We do not know the allocation throughput before the first scavenge.
// TODO(hpayer): Estimate allocation throughput before the first scavenge.
-  if (new_space_allocation_throughput_in_bytes_per_ms == 0) {
-    new_space_allocation_limit =
-        static_cast<size_t>(new_space_size * kConservativeTimeRatio);
-  } else {
+  if (new_space_allocation_throughput_in_bytes_per_ms > 0) {
     // We have to trigger scavenge before we reach the end of new space.
     size_t adjust_limit = new_space_allocation_throughput_in_bytes_per_ms *
                           kTimeUntilNextIdleEvent;
@@ -143,6 +140,13 @@ bool GCIdleTimeHandler::ShouldDoScavenge(
     }
   }

+  if (new_space_allocation_throughput_in_bytes_per_ms <
+      kLowAllocationThroughput) {
+    new_space_allocation_limit =
+        Min(new_space_allocation_limit,
+            static_cast<size_t>(new_space_size * kConservativeTimeRatio));
+  }
+
   // The allocated new space limit to trigger a scavange has to be at least
   // kMinimumNewSpaceSizeToPerformScavenge.
   if (new_space_allocation_limit < kMinimumNewSpaceSizeToPerformScavenge) {
Index: src/heap/gc-idle-time-handler.h
diff --git a/src/heap/gc-idle-time-handler.h b/src/heap/gc-idle-time-handler.h index 8f12a446f2a1609276cf8310f1e06030738dedc7..69e70949b6b1ce9669edbdbc274ac6aaf8f79ffa 100644
--- a/src/heap/gc-idle-time-handler.h
+++ b/src/heap/gc-idle-time-handler.h
@@ -124,6 +124,10 @@ class GCIdleTimeHandler {
   // no idle notification happens.
   static const size_t kTimeUntilNextIdleEvent = 100;

+  // An allocation throughput below kLowAllocationThroughput bytes/ms is
+  // considered low
+  static const size_t kLowAllocationThroughput = 10000;
+
   // If we haven't recorded any scavenger events yet, we use a conservative
   // lower bound for the scavenger speed.
   static const size_t kInitialConservativeScavengeSpeed = 100 * KB;
Index: test/unittests/heap/gc-idle-time-handler-unittest.cc
diff --git a/test/unittests/heap/gc-idle-time-handler-unittest.cc b/test/unittests/heap/gc-idle-time-handler-unittest.cc index c75fde492e5822fbc5d77fb3d5cfa0db9cd2a000..e74152a5fdcf34d251665c431e57fa7b8e895fc0 100644
--- a/test/unittests/heap/gc-idle-time-handler-unittest.cc
+++ b/test/unittests/heap/gc-idle-time-handler-unittest.cc
@@ -156,6 +156,19 @@ TEST_F(GCIdleTimeHandlerTest, DoScavengeLowScavengeSpeed) {
 }


+TEST_F(GCIdleTimeHandlerTest, DoScavengeLowAllocationRate) {
+  GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
+  heap_state.used_new_space_size = kNewSpaceCapacity;
+  heap_state.new_space_allocation_throughput_in_bytes_per_ms =
+      GCIdleTimeHandler::kLowAllocationThroughput - 1;
+  int idle_time_ms = 16;
+  EXPECT_TRUE(GCIdleTimeHandler::ShouldDoScavenge(
+      idle_time_ms, heap_state.new_space_capacity,
+ heap_state.used_new_space_size, heap_state.scavenge_speed_in_bytes_per_ms,
+      heap_state.new_space_allocation_throughput_in_bytes_per_ms));
+}
+
+
 TEST_F(GCIdleTimeHandlerTest, DoScavengeHighScavengeSpeed) {
   GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
   heap_state.used_new_space_size = kNewSpaceCapacity;


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