Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Unified Diff: src/heap/heap.cc

Issue 1175663002: Bring back high promotion mode to shrink young generation size when scavenging latency is high. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 37eb00485f7ae463aadeb41b3a5d3a6b4143a70b..14bb53d1c247178f232afc13a5ae7e97323651c9 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -116,8 +116,11 @@ Heap::Heap()
gc_safe_size_of_old_object_(NULL),
total_regexp_code_generated_(0),
tracer_(this),
+ new_space_high_promotion_mode_active_(false),
high_survival_rate_period_length_(0),
promoted_objects_size_(0),
+ low_survival_rate_period_length_(0),
+ survival_rate_(0),
promotion_ratio_(0),
semi_space_copied_object_size_(0),
previous_semi_space_copied_object_size_(0),
@@ -126,6 +129,8 @@ Heap::Heap()
nodes_copied_in_new_space_(0),
nodes_promoted_(0),
maximum_size_scavenges_(0),
+ previous_survival_rate_trend_(Heap::STABLE),
+ survival_rate_trend_(Heap::STABLE),
max_gc_pause_(0.0),
total_gc_time_ms_(0.0),
max_alive_after_gc_(0),
@@ -1172,6 +1177,24 @@ void Heap::UpdateSurvivalStatistics(int start_new_space_size) {
} else {
high_survival_rate_period_length_ = 0;
}
+
+ if (survival_rate < kYoungSurvivalRateLowThreshold) {
+ low_survival_rate_period_length_++;
+ } else {
+ low_survival_rate_period_length_ = 0;
+ }
+
+ double survival_rate_diff = survival_rate_ - survival_rate;
+
+ if (survival_rate_diff > kYoungSurvivalRateAllowedDeviation) {
+ set_survival_rate_trend(DECREASING);
+ } else if (survival_rate_diff < -kYoungSurvivalRateAllowedDeviation) {
+ set_survival_rate_trend(INCREASING);
+ } else {
+ set_survival_rate_trend(STABLE);
+ }
+
+ survival_rate_ = survival_rate;
}
bool Heap::PerformGarbageCollection(
@@ -1228,6 +1251,7 @@ bool Heap::PerformGarbageCollection(
old_generation_size_at_last_gc_ = PromotedSpaceSizeOfObjects();
UpdateSurvivalStatistics(start_new_space_size);
+ ConfigureNewGenerationSize();
ConfigureInitialOldGenerationSize();
isolate_->counters()->objs_since_last_young()->Set(0);
@@ -1445,7 +1469,8 @@ void Heap::CheckNewSpaceExpansionCriteria() {
survived_since_last_expansion_ = 0;
}
} else if (new_space_.TotalCapacity() < new_space_.MaximumCapacity() &&
- survived_since_last_expansion_ > new_space_.TotalCapacity()) {
+ survived_since_last_expansion_ > new_space_.TotalCapacity() &&
+ !new_space_high_promotion_mode_active_) {
// Grow the size of new space if there is room to grow, and enough data
// has survived scavenge since the last expansion.
new_space_.Grow();
@@ -2479,6 +2504,38 @@ void Heap::ConfigureInitialOldGenerationSize() {
}
+void Heap::ConfigureNewGenerationSize() {
+ if (!new_space_high_promotion_mode_active_ &&
+ new_space_.TotalCapacity() == new_space_.MaximumCapacity() &&
+ IsStableOrIncreasingSurvivalTrend() && IsHighSurvivalRate()) {
+ // Stable high survival rates even though young generation is at
+ // maximum capacity indicates that most objects will be promoted.
+ // To decrease scavenger pauses and final mark-sweep pauses, we
+ // have to limit maximal capacity of the young generation.
+ new_space_high_promotion_mode_active_ = true;
+ if (FLAG_trace_gc) {
+ PrintPID("Limited new space size due to high promotion rate: %d MB\n",
+ new_space_.InitialTotalCapacity() / MB);
+ }
+ } else if (new_space_high_promotion_mode_active_ &&
+ IsStableOrDecreasingSurvivalTrend() && IsLowSurvivalRate()) {
+ // Decreasing low survival rates might indicate that the above high
+ // promotion mode is over and we should allow the young generation
+ // to grow again.
+ new_space_high_promotion_mode_active_ = false;
+ if (FLAG_trace_gc) {
+ PrintPID("Unlimited new space size due to low promotion rate: %d MB\n",
+ new_space_.MaximumCapacity() / MB);
+ }
+ }
+
+ if (new_space_high_promotion_mode_active_ &&
+ new_space_.TotalCapacity() > new_space_.InitialTotalCapacity()) {
+ new_space_.Shrink();
+ }
+}
+
+
AllocationResult Heap::AllocatePartialMap(InstanceType instance_type,
int instance_size) {
Object* result = nullptr;
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698