Reviewers: ulan,
Description:
Scale old generation growing strategy based on allocation rate.
Before we used to scale the growing factor based on freed global handles
(which
may have caused jank when many global handles got freed on site navigation).
BUG=
Please review this at https://codereview.chromium.org/1158433003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+23, -26 lines):
M src/heap/heap.h
M src/heap/heap.cc
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index
21e3b3b06a051bccac2af9bc25819e8cd0e52e33..d7ebf878feb6911ef5cdab321f2d136484936a72
100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -1216,10 +1216,6 @@ bool Heap::PerformGarbageCollection(
// Perform mark-sweep with optional compaction.
MarkCompact();
sweep_generation_++;
- // Temporarily set the limit for case when
PostGarbageCollectionProcessing
- // allocates and triggers GC. The real limit is set at after
- // PostGarbageCollectionProcessing.
- SetOldGenerationAllocationLimit(PromotedSpaceSizeOfObjects(), 0);
old_gen_exhausted_ = false;
old_generation_size_configured_ = true;
} else {
@@ -1257,8 +1253,9 @@ bool Heap::PerformGarbageCollection(
// Register the amount of external allocated memory.
amount_of_external_allocated_memory_at_last_global_gc_ =
amount_of_external_allocated_memory_;
- SetOldGenerationAllocationLimit(PromotedSpaceSizeOfObjects(),
- freed_global_handles);
+ SetOldGenerationAllocationLimit(
+ PromotedSpaceSizeOfObjects(),
+ tracer()->CurrentAllocationThroughputInBytesPerMillisecond());
// We finished a marking cycle. We can uncommit the marking deque until
// we start marking again.
mark_compact_collector_.UncommitMarkingDeque();
@@ -5342,11 +5339,12 @@ intptr_t
Heap::CalculateOldGenerationAllocationLimit(double factor,
}
-void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size,
- int freed_global_handles) {
- const int kMaxHandles = 1000;
- const int kMinHandles = 100;
- const double min_factor = 1.1;
+void Heap::SetOldGenerationAllocationLimit(
+ intptr_t old_gen_size, size_t current_allocation_throughput) {
+ const size_t kHighThroughput = 10000;
+ const size_t kLowThroughput = 1000;
+ const double min_scaling_factor = 1.1;
+ const double max_scaling_factor = 1.5;
double max_factor = 4;
const double idle_max_factor = 1.5;
// We set the old generation growing factor to 2 to grow the heap slower
on
@@ -5355,31 +5353,30 @@ void Heap::SetOldGenerationAllocationLimit(intptr_t
old_gen_size,
max_factor = 2;
}
- // If there are many freed global handles, then the next full GC will
- // likely collect a lot of garbage. Choose the heap growing factor
- // depending on freed global handles.
- // TODO(ulan, hpayer): Take into account mutator utilization.
- // TODO(hpayer): The idle factor could make the handles heuristic
obsolete.
- // Look into that.
double factor;
double idle_factor;
- if (freed_global_handles <= kMinHandles) {
+ if (current_allocation_throughput == 0 ||
+ current_allocation_throughput >= kHighThroughput) {
factor = max_factor;
- } else if (freed_global_handles >= kMaxHandles) {
- factor = min_factor;
+ } else if (current_allocation_throughput <= kLowThroughput) {
+ factor = min_scaling_factor;
} else {
// Compute factor using linear interpolation between points
- // (kMinHandles, max_factor) and (kMaxHandles, min_factor).
- factor = max_factor -
- (freed_global_handles - kMinHandles) * (max_factor -
min_factor) /
- (kMaxHandles - kMinHandles);
+ // (kHighThroughput, max_scaling_factor) and (kLowThroughput,
min_factor).
+ factor = min_scaling_factor +
+ (current_allocation_throughput - kLowThroughput) *
+ (max_scaling_factor - min_scaling_factor) /
+ (kHighThroughput - kLowThroughput);
}
if (FLAG_stress_compaction ||
mark_compact_collector()->reduce_memory_footprint_) {
- factor = min_factor;
+ factor = min_scaling_factor;
}
+ // TODO(hpayer): Investigate if idle_old_generation_allocation_limit_ is
still
+ // needed after taking the allocation rate for the old generation limit
into
+ // account.
idle_factor = Min(factor, idle_max_factor);
old_generation_allocation_limit_ =
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index
ad5ef6601517aa6f9ed82b93a24224be6004d67e..f1cf40818787b3fa4703ff54f539e4f11c05d40a
100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -1153,7 +1153,7 @@ class Heap {
// Sets the allocation limit to trigger the next full garbage collection.
void SetOldGenerationAllocationLimit(intptr_t old_gen_size,
- int freed_global_handles);
+ size_t
current_allocation_throughput);
// Indicates whether inline bump-pointer allocation has been disabled.
bool inline_allocation_disabled() { return inline_allocation_disabled_; }
--
--
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.