Reviewers: Vyacheslav Egorov,

Description:
Change the incremental marking speed-up-to-make-progress heuristic so
that the speed is not reset on a scavenge.  Also tune the constants and
add some explanation.  Increase max heap size on IA32.

Please review this at http://codereview.chromium.org/6773004/

SVN Base: http://v8.googlecode.com/svn/branches/experimental/gc/

Affected files:
  M     src/heap.cc
  M     src/incremental-marking.h
  M     src/incremental-marking.cc
  M     src/spaces.h
  M     src/spaces.cc


Index: src/heap.cc
===================================================================
--- src/heap.cc (revision 7396)
+++ src/heap.cc (working copy)
@@ -98,7 +98,7 @@
 intptr_t Heap::max_executable_size_ = 256*MB;
 #else
 static const int default_max_semispace_size_  = 4*MB;
-intptr_t Heap::max_old_generation_size_ = 512*MB;
+intptr_t Heap::max_old_generation_size_ = 700*MB;
 int Heap::initial_semispace_size_ = 512*KB;
 intptr_t Heap::code_range_size_ = 0;
 intptr_t Heap::max_executable_size_ = 128*MB;
Index: src/incremental-marking.cc
===================================================================
--- src/incremental-marking.cc  (revision 7396)
+++ src/incremental-marking.cc  (working copy)
@@ -239,8 +239,6 @@
 void IncrementalMarking::PrepareForScavenge() {
   if (IsStopped()) return;

-  ResetStepCounters();
-
   Address new_space_low = Heap::new_space()->FromSpaceLow();
   Address new_space_high = Heap::new_space()->FromSpaceHigh();
   Marking::ClearRange(new_space_low,
@@ -376,7 +374,7 @@
       steps_count_++;

       if ((steps_count_ % kAllocationMarkingFactorSpeedupInterval) == 0) {
-        allocation_marking_factor_ *= kAllocationMarkingFactorSpeedup;
+        allocation_marking_factor_ += kAllocationMarkingFactorSpeedup;
       }
     }
   }
Index: src/incremental-marking.h
===================================================================
--- src/incremental-marking.h   (revision 7396)
+++ src/incremental-marking.h   (working copy)
@@ -70,10 +70,18 @@

   static void MarkingComplete();

-  static const intptr_t kAllocatedThreshold = 1024;
-  static const intptr_t kInitialAllocationMarkingFactor = 8;
-  static const intptr_t kAllocationMarkingFactorSpeedupInterval = 512;
-  static const intptr_t kAllocationMarkingFactorSpeedup = 2;
+ // It's hard to know how much work the incremental marker should do to make + // progress in the face of the mutator creating new work for it. We start
+  // of at a moderate rate of work and gradually increase the speed of the
+  // incremental marker until it completes.
+  // Do some marking every time this much memory has been allocated.
+  static const intptr_t kAllocatedThreshold = 8192;
+ // Start off by marking this many times more memory than has been allocated.
+  static const intptr_t kInitialAllocationMarkingFactor = 4;
+  // After this many steps we increase the marking/allocating factor.
+  static const intptr_t kAllocationMarkingFactorSpeedupInterval = 1024;
+  // This is how much we increase the marking/allocating factor by.
+  static const intptr_t kAllocationMarkingFactorSpeedup = 4;

   static void Step(intptr_t allocated);

Index: src/spaces.cc
===================================================================
--- src/spaces.cc       (revision 7396)
+++ src/spaces.cc       (working copy)
@@ -1446,7 +1446,7 @@
     huge_list_ = node;
   }
   available_ += size_in_bytes;
-  ASSERT(available_ == SumFreeLists());
+  ASSERT(IsVeryLong() || available_ == SumFreeLists());
   return 0;
 }

@@ -1496,7 +1496,7 @@
   }

   available_ -= new_node_size;
-  ASSERT(available_ == SumFreeLists());
+  ASSERT(IsVeryLong() || available_ == SumFreeLists());

   int old_linear_size = owner_->limit() - owner_->top();
   // Mark the old linear allocation area with a free space map so it can be
@@ -1547,6 +1547,32 @@
 }


+static const int kVeryLongFreeList = 500;
+
+
+int OldSpaceFreeList::FreeListLength(FreeListNode* cur) {
+  int length = 0;
+  while (cur != NULL) {
+    length++;
+    cur = cur->next();
+    if (length == kVeryLongFreeList) return length;
+  }
+  return length;
+}
+
+
+bool OldSpaceFreeList::IsVeryLong() {
+  if (FreeListLength(small_list_) == kVeryLongFreeList) return  true;
+  if (FreeListLength(medium_list_) == kVeryLongFreeList) return  true;
+  if (FreeListLength(large_list_) == kVeryLongFreeList) return  true;
+  if (FreeListLength(huge_list_) == kVeryLongFreeList) return  true;
+  return false;
+}
+
+
+// This can take a very long time because it is linear in the number of entries
+// on the free list, so it should not be called if FreeListLength returns
+// kVeryLongFreeList.
 intptr_t OldSpaceFreeList::SumFreeLists() {
   intptr_t sum = SumFreeList(small_list_);
   sum += SumFreeList(medium_list_);
Index: src/spaces.h
===================================================================
--- src/spaces.h        (revision 7396)
+++ src/spaces.h        (working copy)
@@ -1125,7 +1125,9 @@
 #ifdef DEBUG
   void Zap();
   static intptr_t SumFreeList(FreeListNode* node);
+  static int FreeListLength(FreeListNode* cur);
   intptr_t SumFreeLists();
+  bool IsVeryLong();
 #endif

  private:


--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev

Reply via email to