Commit 7bdb9069 authored by ulan's avatar ulan Committed by Commit bot

[heap] Reland "Use RAIL mode for initial heap sizing".

The original patch was reverted because of performance
regressions caused by removal of old heap sizing heuristics.

This patch keeps the old heuristics and adds RAIL mode.

BUG=chromium:613518

Review-Url: https://codereview.chromium.org/2576543002
Cr-Commit-Position: refs/heads/master@{#41773}
parent b2b5d0ab
......@@ -5306,6 +5306,13 @@ void Heap::DampenOldGenerationAllocationLimit(size_t old_gen_size,
}
}
bool Heap::ShouldOptimizeForLoadTime() {
return isolate()->rail_mode() == PERFORMANCE_LOAD &&
PromotedTotalSize() < initial_old_generation_size_ &&
MonotonicallyIncreasingTimeInMs() <
isolate()->LoadStartTimeMs() + kMaxLoadTimeMs;
}
// This predicate is called when an old generation space cannot allocated from
// the free list and is about to add a new page. Returning false will cause a
// major GC. It happens when the old generation allocation limit is reached and
......@@ -5317,6 +5324,8 @@ bool Heap::ShouldExpandOldGenerationOnSlowAllocation() {
if (ShouldOptimizeForMemoryUsage()) return false;
if (ShouldOptimizeForLoadTime()) return true;
if (incremental_marking()->NeedsFinalization()) {
return !AllocationLimitOvershotByLargeMargin();
}
......
......@@ -1850,6 +1850,14 @@ class Heap {
// Growing strategy. =========================================================
// ===========================================================================
// For some webpages RAIL mode does not switch from PERFORMANCE_LOAD.
// This constant limits the effect of load RAIL mode on GC.
// The value is arbitrary and chosen as the largest load time observed in
// v8 browsing benchmarks.
static const int kMaxLoadTimeMs = 3000;
bool ShouldOptimizeForLoadTime();
// Decrease the allocation limit if the new limit based on the given
// parameters is lower than the current limit.
void DampenOldGenerationAllocationLimit(size_t old_gen_size, double gc_speed,
......
......@@ -2148,6 +2148,7 @@ Isolate::Isolate(bool enable_serializer)
// be fixed once the default isolate cleanup is done.
random_number_generator_(NULL),
rail_mode_(PERFORMANCE_ANIMATION),
load_start_time_ms_(0),
serializer_enabled_(enable_serializer),
has_fatal_error_(false),
initialized_from_snapshot_(false),
......@@ -3505,8 +3506,22 @@ void Isolate::CheckDetachedContextsAfterGC() {
}
}
double Isolate::LoadStartTimeMs() {
base::LockGuard<base::Mutex> guard(&rail_mutex_);
return load_start_time_ms_;
}
void Isolate::SetRAILMode(RAILMode rail_mode) {
RAILMode old_rail_mode = rail_mode_.Value();
if (old_rail_mode != PERFORMANCE_LOAD && rail_mode == PERFORMANCE_LOAD) {
base::LockGuard<base::Mutex> guard(&rail_mutex_);
load_start_time_ms_ = heap()->MonotonicallyIncreasingTimeInMs();
}
rail_mode_.SetValue(rail_mode);
if (old_rail_mode == PERFORMANCE_LOAD && rail_mode != PERFORMANCE_LOAD) {
heap()->incremental_marking()->incremental_marking_job()->ScheduleTask(
heap());
}
if (FLAG_trace_rail) {
PrintIsolate(this, "RAIL mode: %s\n", RAILModeName(rail_mode));
}
......
......@@ -1177,6 +1177,10 @@ class Isolate {
void SetRAILMode(RAILMode rail_mode);
RAILMode rail_mode() { return rail_mode_.Value(); }
double LoadStartTimeMs();
void IsolateInForegroundNotification();
void IsolateInBackgroundNotification();
......@@ -1362,6 +1366,8 @@ class Isolate {
AccessCompilerData* access_compiler_data_;
base::RandomNumberGenerator* random_number_generator_;
base::AtomicValue<RAILMode> rail_mode_;
base::Mutex rail_mutex_;
double load_start_time_ms_;
// Whether the isolate has been created for snapshotting.
bool serializer_enabled_;
......
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