Reviewers: Hannes Payer,

Message:
PTAL

Description:
Grow heap slowly after running memory reducer.

BUG=

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

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

Affected files (+10, -5 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 4f5a064cca37a0f51ce644a815da5786008d664a..afe7e38726207a63e7c917fafe4202504e62a5f2 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -5672,7 +5672,7 @@ void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size,
                                            double mutator_speed,
                                            int freed_global_handles) {
   const int kFreedGlobalHandlesThreshold = 700;
-  const double kMaxHeapGrowingFactorForManyFreedGlobalHandles = 1.3;
+  const double kConservativeHeapGrowingFactor = 1.3;

   double factor = HeapGrowingFactor(gc_speed, mutator_speed);

@@ -5691,8 +5691,9 @@ void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size,
     factor = Min(factor, kMaxHeapGrowingFactorMemoryConstrained);
   }

-  if (freed_global_handles >= kFreedGlobalHandlesThreshold) {
-    factor = Min(factor, kMaxHeapGrowingFactorForManyFreedGlobalHandles);
+  if (freed_global_handles >= kFreedGlobalHandlesThreshold ||
+      memory_reducer_.ShouldGrowHeapSlowly()) {
+    factor = Min(factor, kConservativeHeapGrowingFactor);
   }

   if (FLAG_stress_compaction ||
Index: src/heap/memory-reducer.cc
diff --git a/src/heap/memory-reducer.cc b/src/heap/memory-reducer.cc
index 7063fc4b2eb5c549ad6c1ba26e350461a4c824da..634220d0c8d9175e3b88e4e9873f3be06aeffad9 100644
--- a/src/heap/memory-reducer.cc
+++ b/src/heap/memory-reducer.cc
@@ -135,7 +135,7 @@ MemoryReducer::State MemoryReducer::Step(const State& state,
           return state;
         case kTimer:
           if (state.started_gcs >= kMaxNumberOfGCs) {
-            return State(kDone, 0, 0.0, state.last_gc_time_ms);
+ return State(kDone, kMaxNumberOfGCs, 0.0, state.last_gc_time_ms);
           } else if (event.can_start_incremental_gc &&
(event.low_allocation_rate || WatchdogGC(state, event))) {
             if (state.next_gc_start_ms <= event.time_ms) {
@@ -169,7 +169,7 @@ MemoryReducer::State MemoryReducer::Step(const State& state, return State(kWait, state.started_gcs, event.time_ms + kShortDelayMs,
                        event.time_ms);
         } else {
-          return State(kDone, 0, 0.0, event.time_ms);
+          return State(kDone, kMaxNumberOfGCs, 0.0, event.time_ms);
         }
       }
   }
Index: src/heap/memory-reducer.h
diff --git a/src/heap/memory-reducer.h b/src/heap/memory-reducer.h
index c96005380cd030841b07cf30830999538a5aa6ea..f98cb045e3854a3ed6cae2a37a3da95c33efff43 100644
--- a/src/heap/memory-reducer.h
+++ b/src/heap/memory-reducer.h
@@ -130,6 +130,10 @@ class MemoryReducer {

   Heap* heap() { return heap_; }

+  bool ShouldGrowHeapSlowly() {
+    return state_.action == kDone && state_.started_gcs > 0;
+  }
+
  private:
   class TimerTask : public v8::internal::CancelableTask {
    public:


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