Commit 0d5dd777 authored by hpayer@chromium.org's avatar hpayer@chromium.org

Simplifying GC heuristics, deleted old generation allocation limit.

BUG=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14780 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d057410e
...@@ -118,8 +118,7 @@ Heap::Heap() ...@@ -118,8 +118,7 @@ Heap::Heap()
disallow_allocation_failure_(false), disallow_allocation_failure_(false),
#endif // DEBUG #endif // DEBUG
new_space_high_promotion_mode_active_(false), new_space_high_promotion_mode_active_(false),
old_gen_promotion_limit_(kMinimumPromotionLimit), old_generation_allocation_limit_(kMinimumOldGenerationAllocationLimit),
old_gen_allocation_limit_(kMinimumAllocationLimit),
size_of_old_gen_at_last_old_space_gc_(0), size_of_old_gen_at_last_old_space_gc_(0),
external_allocation_limit_(0), external_allocation_limit_(0),
amount_of_external_allocated_memory_(0), amount_of_external_allocated_memory_(0),
...@@ -282,7 +281,7 @@ GarbageCollector Heap::SelectGarbageCollector(AllocationSpace space, ...@@ -282,7 +281,7 @@ GarbageCollector Heap::SelectGarbageCollector(AllocationSpace space,
} }
// Is enough data promoted to justify a global GC? // Is enough data promoted to justify a global GC?
if (OldGenerationPromotionLimitReached()) { if (OldGenerationAllocationLimitReached()) {
isolate_->counters()->gc_compactor_caused_by_promoted_data()->Increment(); isolate_->counters()->gc_compactor_caused_by_promoted_data()->Increment();
*reason = "promotion limit reached"; *reason = "promotion limit reached";
return MARK_COMPACTOR; return MARK_COMPACTOR;
...@@ -916,10 +915,8 @@ bool Heap::PerformGarbageCollection(GarbageCollector collector, ...@@ -916,10 +915,8 @@ bool Heap::PerformGarbageCollection(GarbageCollector collector,
size_of_old_gen_at_last_old_space_gc_ = PromotedSpaceSizeOfObjects(); size_of_old_gen_at_last_old_space_gc_ = PromotedSpaceSizeOfObjects();
old_gen_promotion_limit_ = old_generation_allocation_limit_ =
OldGenPromotionLimit(size_of_old_gen_at_last_old_space_gc_); OldGenerationAllocationLimit(size_of_old_gen_at_last_old_space_gc_);
old_gen_allocation_limit_ =
OldGenAllocationLimit(size_of_old_gen_at_last_old_space_gc_);
old_gen_exhausted_ = false; old_gen_exhausted_ = false;
} else { } else {
...@@ -5970,10 +5967,8 @@ void Heap::ReportHeapStatistics(const char* title) { ...@@ -5970,10 +5967,8 @@ void Heap::ReportHeapStatistics(const char* title) {
USE(title); USE(title);
PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n", PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n",
title, gc_count_); title, gc_count_);
PrintF("old_gen_promotion_limit_ %" V8_PTR_PREFIX "d\n", PrintF("old_generation_allocation_limit_ %" V8_PTR_PREFIX "d\n",
old_gen_promotion_limit_); old_generation_allocation_limit_);
PrintF("old_gen_allocation_limit_ %" V8_PTR_PREFIX "d\n",
old_gen_allocation_limit_);
PrintF("\n"); PrintF("\n");
PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles(isolate_)); PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles(isolate_));
......
...@@ -1569,44 +1569,23 @@ class Heap { ...@@ -1569,44 +1569,23 @@ class Heap {
return PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize(); return PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize();
} }
// True if we have reached the allocation limit in the old generation that
// should force the next GC (caused normally) to be a full one.
inline bool OldGenerationPromotionLimitReached() {
return PromotedTotalSize() > old_gen_promotion_limit_;
}
inline intptr_t OldGenerationSpaceAvailable() { inline intptr_t OldGenerationSpaceAvailable() {
return old_gen_allocation_limit_ - PromotedTotalSize(); return old_generation_allocation_limit_ - PromotedTotalSize();
} }
inline intptr_t OldGenerationCapacityAvailable() { inline intptr_t OldGenerationCapacityAvailable() {
return max_old_generation_size_ - PromotedTotalSize(); return max_old_generation_size_ - PromotedTotalSize();
} }
static const intptr_t kMinimumPromotionLimit = 5 * Page::kPageSize; static const intptr_t kMinimumOldGenerationAllocationLimit =
static const intptr_t kMinimumAllocationLimit =
8 * (Page::kPageSize > MB ? Page::kPageSize : MB); 8 * (Page::kPageSize > MB ? Page::kPageSize : MB);
intptr_t OldGenPromotionLimit(intptr_t old_gen_size) { intptr_t OldGenerationAllocationLimit(intptr_t old_gen_size) {
const int divisor = FLAG_stress_compaction ? 10 : const int divisor = FLAG_stress_compaction ? 10 :
new_space_high_promotion_mode_active_ ? 1 : 3; new_space_high_promotion_mode_active_ ? 1 : 3;
intptr_t limit = intptr_t limit =
Max(old_gen_size + old_gen_size / divisor, kMinimumPromotionLimit); Max(old_gen_size + old_gen_size / divisor,
limit += new_space_.Capacity(); kMinimumOldGenerationAllocationLimit);
// TODO(hpayer): Can be removed when when pretenuring is supported for all
// allocation sites.
if (IsHighSurvivalRate() && IsStableOrIncreasingSurvivalTrend()) {
limit *= 2;
}
intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2;
return Min(limit, halfway_to_the_max);
}
intptr_t OldGenAllocationLimit(intptr_t old_gen_size) {
const int divisor = FLAG_stress_compaction ? 8 :
new_space_high_promotion_mode_active_ ? 1 : 2;
intptr_t limit =
Max(old_gen_size + old_gen_size / divisor, kMinimumAllocationLimit);
limit += new_space_.Capacity(); limit += new_space_.Capacity();
// TODO(hpayer): Can be removed when when pretenuring is supported for all // TODO(hpayer): Can be removed when when pretenuring is supported for all
// allocation sites. // allocation sites.
...@@ -1687,22 +1666,14 @@ class Heap { ...@@ -1687,22 +1666,14 @@ class Heap {
if (FLAG_stress_compaction && (gc_count_ & 1) != 0) return true; if (FLAG_stress_compaction && (gc_count_ & 1) != 0) return true;
intptr_t total_promoted = PromotedTotalSize();
intptr_t adjusted_promotion_limit =
old_gen_promotion_limit_ - new_space_.Capacity();
if (total_promoted >= adjusted_promotion_limit) return true;
intptr_t adjusted_allocation_limit = intptr_t adjusted_allocation_limit =
old_gen_allocation_limit_ - new_space_.Capacity() / 5; old_generation_allocation_limit_ - new_space_.Capacity();
if (PromotedSpaceSizeOfObjects() >= adjusted_allocation_limit) return true; if (PromotedTotalSize() >= adjusted_allocation_limit) return true;
return false; return false;
} }
void UpdateNewSpaceReferencesInExternalStringTable( void UpdateNewSpaceReferencesInExternalStringTable(
ExternalStringTableUpdaterCallback updater_func); ExternalStringTableUpdaterCallback updater_func);
...@@ -2027,13 +1998,9 @@ class Heap { ...@@ -2027,13 +1998,9 @@ class Heap {
// Limit that triggers a global GC on the next (normally caused) GC. This // Limit that triggers a global GC on the next (normally caused) GC. This
// is checked when we have already decided to do a GC to help determine // is checked when we have already decided to do a GC to help determine
// which collector to invoke. // which collector to invoke, before expanding a paged space in the old
intptr_t old_gen_promotion_limit_; // generation and on every allocation in large object space.
intptr_t old_generation_allocation_limit_;
// Limit that triggers a global GC as soon as is reasonable. This is
// checked before expanding a paged space in the old generation and on
// every allocation in large object space.
intptr_t old_gen_allocation_limit_;
// Used to adjust the limits that control the timing of the next GC. // Used to adjust the limits that control the timing of the next GC.
intptr_t size_of_old_gen_at_last_old_space_gc_; intptr_t size_of_old_gen_at_last_old_space_gc_;
...@@ -2051,7 +2018,7 @@ class Heap { ...@@ -2051,7 +2018,7 @@ class Heap {
// Indicates that an allocation has failed in the old generation since the // Indicates that an allocation has failed in the old generation since the
// last GC. // last GC.
int old_gen_exhausted_; bool old_gen_exhausted_;
Object* native_contexts_list_; Object* native_contexts_list_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment