Take into account freed global handles for heap growing.
authorulan <ulan@chromium.org>
Fri, 31 Jul 2015 08:59:58 +0000 (01:59 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 31 Jul 2015 09:00:10 +0000 (09:00 +0000)
This partially brings back the heuristic from v8 4.44.

BUG=

Review URL: https://codereview.chromium.org/1269743002

Cr-Commit-Position: refs/heads/master@{#29947}

src/heap/heap.cc
src/heap/heap.h

index 83bd5428dd74b8555439ae7444018a929057c87d..49c327be29557ee33e59bc040ba6ea61bdd4bab7 100644 (file)
@@ -1327,7 +1327,8 @@ bool Heap::PerformGarbageCollection(
     // Register the amount of external allocated memory.
     amount_of_external_allocated_memory_at_last_global_gc_ =
         amount_of_external_allocated_memory_;
-    SetOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed);
+    SetOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed,
+                                    freed_global_handles);
   } else if (HasLowYoungGenerationAllocationRate() &&
              old_generation_size_configured_) {
     DampenOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed);
@@ -5655,7 +5656,11 @@ intptr_t Heap::CalculateOldGenerationAllocationLimit(double factor,
 
 void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size,
                                            double gc_speed,
-                                           double mutator_speed) {
+                                           double mutator_speed,
+                                           int freed_global_handles) {
+  const int kFreedGlobalHandlesThreshold = 700;
+  const double kMaxHeapGrowingFactorForManyFreedGlobalHandles = 1.3;
+
   double factor = HeapGrowingFactor(gc_speed, mutator_speed);
 
   if (FLAG_trace_gc_verbose) {
@@ -5673,6 +5678,10 @@ void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size,
     factor = Min(factor, kMaxHeapGrowingFactorMemoryConstrained);
   }
 
+  if (freed_global_handles >= kFreedGlobalHandlesThreshold) {
+    factor = Min(factor, kMaxHeapGrowingFactorForManyFreedGlobalHandles);
+  }
+
   if (FLAG_stress_compaction ||
       mark_compact_collector()->reduce_memory_footprint_) {
     factor = kMinHeapGrowingFactor;
index 15577ee02390be901caa9e71bd30cfca41fe2889..be511aee481f4e9d4742cbe1fd14c7e2ff91e153 100644 (file)
@@ -1179,7 +1179,8 @@ class Heap {
 
   // Sets the allocation limit to trigger the next full garbage collection.
   void SetOldGenerationAllocationLimit(intptr_t old_gen_size, double gc_speed,
-                                       double mutator_speed);
+                                       double mutator_speed,
+                                       int freed_global_handles);
 
   // Decrease the allocation limit if the new limit based on the given
   // parameters is lower than the current limit.