Partially revert https://crrev.com/7e53749df0a10f475404e86ef0ca8df02bb79e7a
authorulan <ulan@chromium.org>
Thu, 6 Aug 2015 16:05:14 +0000 (09:05 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 6 Aug 2015 16:05:25 +0000 (16:05 +0000)
This fixes memory regression caused by not reducing new-space size.

BUG=chromium:517468
LOG=NO

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

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

src/heap/gc-tracer.cc
src/heap/gc-tracer.h
src/heap/heap.cc

index a231a8e..7dbe5fc 100644 (file)
@@ -702,11 +702,15 @@ size_t GCTracer::AllocationThroughputInBytesPerMillisecond(
 }
 
 
+size_t GCTracer::CurrentAllocationThroughputInBytesPerMillisecond() const {
+  return AllocationThroughputInBytesPerMillisecond(kThroughputTimeFrameMs);
+}
+
+
 size_t GCTracer::CurrentOldGenerationAllocationThroughputInBytesPerMillisecond()
     const {
-  static const double kThroughputTimeFrame = 5000;
   return OldGenerationAllocationThroughputInBytesPerMillisecond(
-      kThroughputTimeFrame);
+      kThroughputTimeFrameMs);
 }
 
 
index 811266e..9f383bf 100644 (file)
@@ -299,6 +299,8 @@ class GCTracer {
 
   typedef RingBuffer<SurvivalEvent, kRingBufferMaxSize> SurvivalEventBuffer;
 
+  static const int kThroughputTimeFrameMs = 5000;
+
   explicit GCTracer(Heap* heap);
 
   // Start collecting data.
@@ -416,6 +418,11 @@ class GCTracer {
   // Returns 0 if no allocation events have been recorded.
   size_t AllocationThroughputInBytesPerMillisecond(double time_ms) const;
 
+  // Allocation throughput in heap in bytes/milliseconds in
+  // the last five seconds.
+  // Returns 0 if no allocation events have been recorded.
+  size_t CurrentAllocationThroughputInBytesPerMillisecond() const;
+
   // Allocation throughput in old generation in bytes/milliseconds in
   // the last five seconds.
   // Returns 0 if no allocation events have been recorded.
index e37c9f6..4647157 100644 (file)
@@ -4763,7 +4763,13 @@ bool Heap::HasHighFragmentation(intptr_t used, intptr_t committed) {
 
 
 void Heap::ReduceNewSpaceSize() {
-  if (!FLAG_predictable && HasLowAllocationRate()) {
+  // TODO(ulan): Unify this constant with the similar constant in
+  // GCIdleTimeHandler once the change is merged to 4.5.
+  static const size_t kLowAllocationThroughput = 1000;
+  size_t allocation_throughput =
+      tracer()->CurrentAllocationThroughputInBytesPerMillisecond();
+  if (FLAG_predictable || allocation_throughput == 0) return;
+  if (allocation_throughput < kLowAllocationThroughput) {
     new_space_.Shrink();
     UncommitFromSpace();
   }