Reviewers: kasperl, Description: Changed the expansion of new space to depend on how much has survived scavenge. This replaces the fixed expansion policy based on number of scavenges. Increased the max new space size to 8MB (only reserved space). Increased the defalt new space size to 512KB.
Please review this at http://codereview.chromium.org/125046 SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M src/heap.h M src/heap.cc Index: src/heap.cc =================================================================== --- src/heap.cc (revision 2150) +++ src/heap.cc (working copy) @@ -79,9 +79,9 @@ // semispace_size_ should be a power of 2 and old_generation_size_ should be // a multiple of Page::kPageSize. -int Heap::semispace_size_ = 2*MB; +int Heap::semispace_size_ = 8*MB; int Heap::old_generation_size_ = 512*MB; -int Heap::initial_semispace_size_ = 256*KB; +int Heap::initial_semispace_size_ = 512*KB; GCCallback Heap::global_gc_prologue_callback_ = NULL; GCCallback Heap::global_gc_epilogue_callback_ = NULL; @@ -90,9 +90,8 @@ // ConfigureHeap. int Heap::young_generation_size_ = 0; // Will be 2 * semispace_size_. -// Double the new space after this many scavenge collections. -int Heap::new_space_growth_limit_ = 8; -int Heap::scavenge_count_ = 0; +int Heap::survived_since_last_expansion_ = 0; + Heap::HeapState Heap::gc_state_ = NOT_IN_GC; int Heap::mc_count_ = 0; @@ -421,7 +420,7 @@ old_gen_promotion_limit_ = old_gen_size + Max(kMinimumPromotionLimit, old_gen_size / 3); old_gen_allocation_limit_ = - old_gen_size + Max(kMinimumAllocationLimit, old_gen_size / 3); + old_gen_size + Max(kMinimumAllocationLimit, old_gen_size / 2); old_gen_exhausted_ = false; // If we have used the mark-compact collector to collect the new @@ -624,16 +623,17 @@ // Implements Cheney's copying algorithm LOG(ResourceEvent("scavenge", "begin")); - scavenge_count_++; + // Used for updating survived_since_last_expansion_ at function end. + int survived_watermark = PromotedSpaceSize(); + if (new_space_.Capacity() < new_space_.MaximumCapacity() && - scavenge_count_ > new_space_growth_limit_) { - // Double the size of the new space, and double the limit. The next - // doubling attempt will occur after the current new_space_growth_limit_ - // more collections. + survived_since_last_expansion_ > new_space_.Capacity()) { + // Double the size of new space if there is room to grow and enough + // data has survived scavenge since the last expansion. // TODO(1240712): NewSpace::Double has a return value which is // ignored here. new_space_.Double(); - new_space_growth_limit_ *= 2; + survived_since_last_expansion_ = 0; } // Flip the semispaces. After flipping, to space is empty, from space has @@ -737,6 +737,10 @@ // Set age mark. new_space_.set_age_mark(new_space_.top()); + // Update how much has survivived scavenge. + survived_since_last_expansion_ += + PromotedSpaceSize() + new_space_.Size() - survived_watermark; + LOG(ResourceEvent("scavenge", "end")); gc_state_ = NOT_IN_GC; Index: src/heap.h =================================================================== --- src/heap.h (revision 2150) +++ src/heap.h (working copy) @@ -827,8 +827,9 @@ static int young_generation_size_; static int old_generation_size_; - static int new_space_growth_limit_; - static int scavenge_count_; + // For keeping track of how much data has survived + // scavenge since last new space expansion. + static int survived_since_last_expansion_; static int always_allocate_scope_depth_; static bool context_disposed_pending_; --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
