Reviewers: Hannes Payer,

Message:
PTAL

In local testing I observed that memory reducer can time long time to kick in
because it doesn't use the current allocation rate.

Description:
Memory reducer should use the current allocation rate instead of the overall
allocation rate.

BUG=

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

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

Affected files (+22, -5 lines):
  M src/heap/gc-tracer.h
  M src/heap/gc-tracer.cc
  M src/heap/heap.cc
  M src/heap/memory-reducer.cc


Index: src/heap/gc-tracer.cc
diff --git a/src/heap/gc-tracer.cc b/src/heap/gc-tracer.cc
index a231a8eea2f57b4d1703a486bbd570ded0141a85..454b3ac0b05ad72fca6c5bf7841c37c7aaac2d58 100644
--- a/src/heap/gc-tracer.cc
+++ b/src/heap/gc-tracer.cc
@@ -702,11 +702,17 @@ size_t GCTracer::AllocationThroughputInBytesPerMillisecond(
 }


+size_t GCTracer::CurrentNewSpaceAllocationThroughputInBytesPerMillisecond()
+    const {
+  return NewSpaceAllocationThroughputInBytesPerMillisecond(
+      kThroughputTimeFrameMs);
+}
+
+
size_t GCTracer::CurrentOldGenerationAllocationThroughputInBytesPerMillisecond()
     const {
-  static const double kThroughputTimeFrame = 5000;
   return OldGenerationAllocationThroughputInBytesPerMillisecond(
-      kThroughputTimeFrame);
+      kThroughputTimeFrameMs);
 }


Index: src/heap/gc-tracer.h
diff --git a/src/heap/gc-tracer.h b/src/heap/gc-tracer.h
index 811266e92e29c4fbf45fc980db58fe72eaec1ac4..7359b14183335f109c0459296a405eb959ab0816 100644
--- a/src/heap/gc-tracer.h
+++ b/src/heap/gc-tracer.h
@@ -288,6 +288,8 @@ class GCTracer {
     double scopes[Scope::NUMBER_OF_SCOPES];
   };

+  static const int kThroughputTimeFrameMs = 5000;
+
   static const size_t kRingBufferMaxSize = 10;

   typedef RingBuffer<Event, kRingBufferMaxSize> EventBuffer;
@@ -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 new space in bytes/milliseconds in
+  // the last five seconds.
+  // Returns 0 if no allocation events have been recorded.
+  size_t CurrentNewSpaceAllocationThroughputInBytesPerMillisecond() const;
+
   // Allocation throughput in old generation in bytes/milliseconds in
   // the last five seconds.
   // Returns 0 if no allocation events have been recorded.
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 6dc67fcffe69b91183035911750c3356141d4229..1cb3ce82697b245e1718dfd036b8bfe239c574b3 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -4757,7 +4757,7 @@ static double ComputeMutatorUtilization(double mutator_speed, double gc_speed) {

 double Heap::YoungGenerationMutatorUtilization() {
   double mutator_speed = static_cast<double>(
-      tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond());
+ tracer()->CurrentNewSpaceAllocationThroughputInBytesPerMillisecond());
   double gc_speed = static_cast<double>(
       tracer()->ScavengeSpeedInBytesPerMillisecond(kForSurvivedObjects));
   double result = ComputeMutatorUtilization(mutator_speed, gc_speed);
@@ -4773,7 +4773,8 @@ double Heap::YoungGenerationMutatorUtilization() {

 double Heap::OldGenerationMutatorUtilization() {
   double mutator_speed = static_cast<double>(
-      tracer()->OldGenerationAllocationThroughputInBytesPerMillisecond());
+      tracer()
+ ->CurrentOldGenerationAllocationThroughputInBytesPerMillisecond());
   double gc_speed = static_cast<double>(
       tracer()->CombinedMarkCompactSpeedInBytesPerMillisecond());
   double result = ComputeMutatorUtilization(mutator_speed, gc_speed);
Index: src/heap/memory-reducer.cc
diff --git a/src/heap/memory-reducer.cc b/src/heap/memory-reducer.cc
index 7063fc4b2eb5c549ad6c1ba26e350461a4c824da..252b9737253acc7d62ff1d58ab39120a664cda5d 100644
--- a/src/heap/memory-reducer.cc
+++ b/src/heap/memory-reducer.cc
@@ -24,9 +24,12 @@ MemoryReducer::TimerTask::TimerTask(MemoryReducer* memory_reducer)

 void MemoryReducer::TimerTask::RunInternal() {
   Heap* heap = memory_reducer_->heap();
+  double time_ms = heap->MonotonicallyIncreasingTimeInMs();
+ heap->tracer()->SampleAllocation(time_ms, heap->NewSpaceAllocationCounter(),
+                                   heap->OldGenerationAllocationCounter());
   Event event;
   event.type = kTimer;
-  event.time_ms = heap->MonotonicallyIncreasingTimeInMs();
+  event.time_ms = time_ms;
   event.low_allocation_rate = heap->HasLowAllocationRate();
   event.can_start_incremental_gc =
       heap->incremental_marking()->IsStopped() &&


--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to