Reviewers: jochen, ulan,

Message:
PTAL As discussed offline, this may reduce jank in apps where scavenging times
are high.

Description:
Reduce new space size when average scavenging time is high

BUG=

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

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

Affected files (+20, -6 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 38968ad0b33b026b2a6087a908044a9026d8c009..da7119d21ab813ee4eb37a9cdef2ca1c3aab13d6 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -740,7 +740,8 @@ void Heap::GarbageCollectionEpilogue() {
   last_gc_time_ = MonotonicallyIncreasingTimeInMs();

   ReduceNewSpaceSize(
-      tracer()->CurrentAllocationThroughputInBytesPerMillisecond());
+      tracer()->CurrentAllocationThroughputInBytesPerMillisecond(),
+      tracer()->MeanScavengerDuration());
 }


@@ -4620,10 +4621,21 @@ bool Heap::HasLowAllocationRate(size_t allocation_rate) {
 }


-void Heap::ReduceNewSpaceSize(size_t allocation_rate) {
-  if (!FLAG_predictable && HasLowAllocationRate(allocation_rate)) {
-    new_space_.Shrink();
-    UncommitFromSpace();
+bool Heap::HasHighScavengingLatency(size_t scavenging_time) {
+  static const size_t kHighScavengingLatencyInMs = 10;
+  return scavenging_time > kHighScavengingLatencyInMs;
+}
+
+
+void Heap::ReduceNewSpaceSize(size_t allocation_rate, size_t scavenging_time) {
+  if (!FLAG_predictable) {
+    if (HasLowAllocationRate(allocation_rate) ||
+        HasHighScavengingLatency(scavenging_time)) {
+      new_space_.Shrink();
+    }
+    if (HasLowAllocationRate(allocation_rate)) {
+      UncommitFromSpace();
+    }
   }
 }

Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index 8574d55993d9dc523dc233170b3c667ebefe7c26..aa605b693a352a20f2b2c9ab2d720afd2835afe4 100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -2160,7 +2160,9 @@ class Heap {

   bool HasLowAllocationRate(size_t allocaion_rate);

-  void ReduceNewSpaceSize(size_t allocaion_rate);
+  bool HasHighScavengingLatency(size_t scavenging_time);
+
+  void ReduceNewSpaceSize(size_t allocaion_rate, size_t scavenging_time);

   bool TryFinalizeIdleIncrementalMarking(
       double idle_time_in_ms, size_t 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