Commit 37be1d5e authored by hpayer's avatar hpayer Committed by Commit bot

Bring back high promotion mode to shrink young generation size when scavenging latency is high.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#28893}
parent 4d6c3097
......@@ -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),
......@@ -1170,6 +1175,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(
......@@ -1227,6 +1250,7 @@ bool Heap::PerformGarbageCollection(
UpdateSurvivalStatistics(start_new_space_size);
ConfigureNewGenerationSize();
ConfigureInitialOldGenerationSize();
isolate_->counters()->objs_since_last_young()->Set(0);
......@@ -1444,7 +1468,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();
......@@ -2478,6 +2503,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;
......
......@@ -2112,13 +2112,19 @@ class Heap {
void UpdateSurvivalStatistics(int start_new_space_size);
enum SurvivalRateTrend { INCREASING, STABLE, DECREASING, FLUCTUATING };
static const int kYoungSurvivalRateHighThreshold = 90;
static const int kYoungSurvivalRateLowThreshold = 10;
static const int kYoungSurvivalRateAllowedDeviation = 15;
static const int kOldSurvivalRateLowThreshold = 10;
bool new_space_high_promotion_mode_active_;
int high_survival_rate_period_length_;
intptr_t promoted_objects_size_;
int low_survival_rate_period_length_;
double survival_rate_;
double promotion_ratio_;
double promotion_rate_;
intptr_t semi_space_copied_object_size_;
......@@ -2134,12 +2140,61 @@ class Heap {
// of the allocation site.
unsigned int maximum_size_scavenges_;
SurvivalRateTrend previous_survival_rate_trend_;
SurvivalRateTrend survival_rate_trend_;
void set_survival_rate_trend(SurvivalRateTrend survival_rate_trend) {
DCHECK(survival_rate_trend != FLUCTUATING);
previous_survival_rate_trend_ = survival_rate_trend_;
survival_rate_trend_ = survival_rate_trend;
}
SurvivalRateTrend survival_rate_trend() {
if (survival_rate_trend_ == STABLE) {
return STABLE;
} else if (previous_survival_rate_trend_ == STABLE) {
return survival_rate_trend_;
} else if (survival_rate_trend_ != previous_survival_rate_trend_) {
return FLUCTUATING;
} else {
return survival_rate_trend_;
}
}
bool IsStableOrIncreasingSurvivalTrend() {
switch (survival_rate_trend()) {
case STABLE:
case INCREASING:
return true;
default:
return false;
}
}
bool IsStableOrDecreasingSurvivalTrend() {
switch (survival_rate_trend()) {
case STABLE:
case DECREASING:
return true;
default:
return false;
}
}
bool IsIncreasingSurvivalTrend() {
return survival_rate_trend() == INCREASING;
}
bool IsLowSurvivalRate() { return low_survival_rate_period_length_ > 0; }
// TODO(hpayer): Allocation site pretenuring may make this method obsolete.
// Re-visit incremental marking heuristics.
bool IsHighSurvivalRate() { return high_survival_rate_period_length_ > 0; }
void ConfigureInitialOldGenerationSize();
void ConfigureNewGenerationSize();
void SelectScavengingVisitorsTable();
bool HasLowYoungGenerationAllocationRate();
......
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