Reviewers: ulan,

Description:
Always shrink initial old generation size based on survival rate.

BUG=

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

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

Affected files (+24, -25 lines):
  M src/heap/gc-tracer.h
  M src/heap/gc-tracer.cc
  M src/heap/heap.h
  M src/heap/heap.cc


Index: src/heap/gc-tracer.cc
diff --git a/src/heap/gc-tracer.cc b/src/heap/gc-tracer.cc
index 6843e211c472735d70d030a802dd9ab5a6adc7eb..6f550aabffa8c59b5865f2f1a02044e6a7005d53 100644
--- a/src/heap/gc-tracer.cc
+++ b/src/heap/gc-tracer.cc
@@ -31,7 +31,7 @@ GCTracer::ContextDisposalEvent::ContextDisposalEvent(double time) {
 }


-GCTracer::PromotionEvent::PromotionEvent(double promotion_ratio) {
+GCTracer::SurvivalEvent::SurvivalEvent(double promotion_ratio) {
   promotion_ratio_ = promotion_ratio;
 }

@@ -257,8 +257,8 @@ void GCTracer::AddContextDisposalTime(double time) {
 }


-void GCTracer::AddPromotionRatio(double promotion_ratio) {
-  promotion_events_.push_front(PromotionEvent(promotion_ratio));
+void GCTracer::AddSurvivalRatio(double promotion_ratio) {
+  survival_events_.push_front(SurvivalEvent(promotion_ratio));
 }


@@ -374,7 +374,7 @@ void GCTracer::PrintNVP() const {
   PrintF("nodes_copied_in_new=%d ", heap_->nodes_copied_in_new_space_);
   PrintF("nodes_promoted=%d ", heap_->nodes_promoted_);
   PrintF("promotion_ratio=%.1f%% ", heap_->promotion_ratio_);
-  PrintF("average_promotion_ratio=%.1f%% ", AveragePromotionRatio());
+  PrintF("average_survival_ratio=%.1f%% ", AverageSurvivalRatio());
   PrintF("promotion_rate=%.1f%% ", heap_->promotion_rate_);
   PrintF("semi_space_copy_rate=%.1f%% ", heap_->semi_space_copied_rate_);
   PrintF("new_space_allocation_throughput=%" V8_PTR_PREFIX "d ",
@@ -572,25 +572,25 @@ double GCTracer::ContextDisposalRateInMilliseconds() const {
 }


-double GCTracer::AveragePromotionRatio() const {
-  if (promotion_events_.size() == 0) return 0.0;
+double GCTracer::AverageSurvivalRatio() const {
+  if (survival_events_.size() == 0) return 0.0;

   double sum_of_rates = 0.0;
-  PromotionEventBuffer::const_iterator iter = promotion_events_.begin();
-  while (iter != promotion_events_.end()) {
+  SurvivalEventBuffer::const_iterator iter = survival_events_.begin();
+  while (iter != survival_events_.end()) {
     sum_of_rates += iter->promotion_ratio_;
     ++iter;
   }

-  return sum_of_rates / static_cast<double>(promotion_events_.size());
+  return sum_of_rates / static_cast<double>(survival_events_.size());
 }


 bool GCTracer::SurvivalEventsRecorded() const {
-  return promotion_events_.size() > 0;
+  return survival_events_.size() > 0;
 }


-void GCTracer::ResetSurvivalEvents() { promotion_events_.reset(); }
+void GCTracer::ResetSurvivalEvents() { survival_events_.reset(); }
 }
 }  // namespace v8::internal
Index: src/heap/gc-tracer.h
diff --git a/src/heap/gc-tracer.h b/src/heap/gc-tracer.h
index dc8105e7d4cc019eeb747b9fb8b29cf659bad19d..ca144b24b4801a808c1cbcfb77544b582dbd0cf9 100644
--- a/src/heap/gc-tracer.h
+++ b/src/heap/gc-tracer.h
@@ -165,12 +165,12 @@ class GCTracer {
   };


-  class PromotionEvent {
+  class SurvivalEvent {
    public:
     // Default constructor leaves the event uninitialized.
-    PromotionEvent() {}
+    SurvivalEvent() {}

-    explicit PromotionEvent(double promotion_ratio);
+    explicit SurvivalEvent(double survival_ratio);

     double promotion_ratio_;
   };
@@ -284,7 +284,7 @@ class GCTracer {
   typedef RingBuffer<ContextDisposalEvent, kRingBufferMaxSize>
       ContextDisposalEventBuffer;

- typedef RingBuffer<PromotionEvent, kRingBufferMaxSize> PromotionEventBuffer; + typedef RingBuffer<SurvivalEvent, kRingBufferMaxSize> SurvivalEventBuffer;

   explicit GCTracer(Heap* heap);

@@ -300,7 +300,7 @@ class GCTracer {

   void AddContextDisposalTime(double time);

-  void AddPromotionRatio(double promotion_ratio);
+  void AddSurvivalRatio(double survival_ratio);

   // Log an incremental marking step.
   void AddIncrementalMarkingStep(double duration, intptr_t bytes);
@@ -388,10 +388,10 @@ class GCTracer {
   // Returns 0 if no events have been recorded.
   double ContextDisposalRateInMilliseconds() const;

- // Computes the average promotion ratio based on the last recorded promotion + // Computes the average survival ratio based on the last recorded survival
   // events.
   // Returns 0 if no events have been recorded.
-  double AveragePromotionRatio() const;
+  double AverageSurvivalRatio() const;

   // Returns true if at least one survival event was recorded.
   bool SurvivalEventsRecorded() const;
@@ -452,8 +452,8 @@ class GCTracer {
   // RingBuffer for context disposal events.
   ContextDisposalEventBuffer context_disposal_events_;

-  // RingBuffer for promotion events.
-  PromotionEventBuffer promotion_events_;
+  // RingBuffer for survival events.
+  SurvivalEventBuffer survival_events_;

// Cumulative number of incremental marking steps since creation of tracer.
   int cumulative_incremental_marking_steps_;
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index d4cd78ebdaa7f1161ff56ea45a5cfdf6f6fe3e8e..a67bf050b2ee2aa6c677aff8d1cd308d05f654ea 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -1092,8 +1092,6 @@ void Heap::UpdateSurvivalStatistics(int start_new_space_size) {
   promotion_ratio_ = (static_cast<double>(promoted_objects_size_) /
                       static_cast<double>(start_new_space_size) * 100);

-  if (gc_count_ > 1) tracer()->AddPromotionRatio(promotion_ratio_);
-
   if (previous_semi_space_copied_object_size_ > 0) {
     promotion_rate_ =
         (static_cast<double>(promoted_objects_size_) /
@@ -1107,6 +1105,7 @@ void Heap::UpdateSurvivalStatistics(int start_new_space_size) {
        static_cast<double>(start_new_space_size) * 100);

   double survival_rate = promotion_ratio_ + semi_space_copied_rate_;
+  tracer()->AddSurvivalRatio(survival_rate);
   if (survival_rate > kYoungSurvivalRateHighThreshold) {
     high_survival_rate_period_length_++;
   } else {
@@ -2418,8 +2417,8 @@ void Heap::ConfigureInitialOldGenerationSize() {
     old_generation_allocation_limit_ =
         Max(kMinimumOldGenerationAllocationLimit,
             static_cast<intptr_t>(
-                static_cast<double>(initial_old_generation_size_) *
-                (tracer()->AveragePromotionRatio() / 100)));
+                static_cast<double>(old_generation_allocation_limit_) *
+                (tracer()->AverageSurvivalRatio() / 100)));
   }
 }

Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index 23d634001b1a8ce2b2594fbf62c957d2f85f860c..0b353b70f1d269a79b747f65cedc23fc0d487958 100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -1084,7 +1084,7 @@ class Heap {
   static const intptr_t kMinimumOldGenerationAllocationLimit =
       8 * (Page::kPageSize > MB ? Page::kPageSize : MB);

-  static const int kInitalOldGenerationLimitFactor = 7;
+  static const int kInitalOldGenerationLimitFactor = 2;

   static const int kPointerMultiplier = i::kPointerSize / 4;



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