Commit 984e6aed authored by ulan's avatar ulan Committed by Commit bot

[heap] Remove js call rate heuristic from memory reducer.

This is an experiment to check whether the heuristics is still useful.

BUG=

Review-Url: https://codereview.chromium.org/2482163002
Cr-Commit-Position: refs/heads/master@{#40833}
parent a5d251de
...@@ -198,7 +198,6 @@ class CallDepthScope { ...@@ -198,7 +198,6 @@ class CallDepthScope {
: isolate_(isolate), context_(context), escaped_(false) { : isolate_(isolate), context_(context), escaped_(false) {
// TODO(dcarney): remove this when blink stops crashing. // TODO(dcarney): remove this when blink stops crashing.
DCHECK(!isolate_->external_caught_exception()); DCHECK(!isolate_->external_caught_exception());
isolate_->IncrementJsCallsFromApiCounter();
isolate_->handle_scope_implementer()->IncrementCallDepth(); isolate_->handle_scope_implementer()->IncrementCallDepth();
if (!context.IsEmpty()) { if (!context.IsEmpty()) {
i::Handle<i::Context> env = Utils::OpenHandle(*context); i::Handle<i::Context> env = Utils::OpenHandle(*context);
......
...@@ -24,19 +24,16 @@ MemoryReducer::TimerTask::TimerTask(MemoryReducer* memory_reducer) ...@@ -24,19 +24,16 @@ MemoryReducer::TimerTask::TimerTask(MemoryReducer* memory_reducer)
void MemoryReducer::TimerTask::RunInternal() { void MemoryReducer::TimerTask::RunInternal() {
const double kJsCallsPerMsThreshold = 0.5;
Heap* heap = memory_reducer_->heap(); Heap* heap = memory_reducer_->heap();
Event event; Event event;
double time_ms = heap->MonotonicallyIncreasingTimeInMs(); double time_ms = heap->MonotonicallyIncreasingTimeInMs();
heap->tracer()->SampleAllocation(time_ms, heap->NewSpaceAllocationCounter(), heap->tracer()->SampleAllocation(time_ms, heap->NewSpaceAllocationCounter(),
heap->OldGenerationAllocationCounter()); heap->OldGenerationAllocationCounter());
double js_call_rate = memory_reducer_->SampleAndGetJsCallsPerMs(time_ms);
bool low_allocation_rate = heap->HasLowAllocationRate(); bool low_allocation_rate = heap->HasLowAllocationRate();
bool is_idle = js_call_rate < kJsCallsPerMsThreshold && low_allocation_rate;
bool optimize_for_memory = heap->ShouldOptimizeForMemoryUsage(); bool optimize_for_memory = heap->ShouldOptimizeForMemoryUsage();
if (FLAG_trace_gc_verbose) { if (FLAG_trace_gc_verbose) {
heap->isolate()->PrintWithTimestamp( heap->isolate()->PrintWithTimestamp(
"Memory reducer: call rate %.3lf, %s, %s\n", js_call_rate, "Memory reducer: %s, %s\n",
low_allocation_rate ? "low alloc" : "high alloc", low_allocation_rate ? "low alloc" : "high alloc",
optimize_for_memory ? "background" : "foreground"); optimize_for_memory ? "background" : "foreground");
} }
...@@ -45,7 +42,8 @@ void MemoryReducer::TimerTask::RunInternal() { ...@@ -45,7 +42,8 @@ void MemoryReducer::TimerTask::RunInternal() {
// The memory reducer will start incremental markig if // The memory reducer will start incremental markig if
// 1) mutator is likely idle: js call rate is low and allocation rate is low. // 1) mutator is likely idle: js call rate is low and allocation rate is low.
// 2) mutator is in background: optimize for memory flag is set. // 2) mutator is in background: optimize for memory flag is set.
event.should_start_incremental_gc = is_idle || optimize_for_memory; event.should_start_incremental_gc =
low_allocation_rate || optimize_for_memory;
event.can_start_incremental_gc = event.can_start_incremental_gc =
heap->incremental_marking()->IsStopped() && heap->incremental_marking()->IsStopped() &&
(heap->incremental_marking()->CanBeActivated() || optimize_for_memory); (heap->incremental_marking()->CanBeActivated() || optimize_for_memory);
...@@ -53,16 +51,6 @@ void MemoryReducer::TimerTask::RunInternal() { ...@@ -53,16 +51,6 @@ void MemoryReducer::TimerTask::RunInternal() {
} }
double MemoryReducer::SampleAndGetJsCallsPerMs(double time_ms) {
unsigned int counter = heap()->isolate()->js_calls_from_api_counter();
unsigned int call_delta = counter - js_calls_counter_;
double time_delta_ms = time_ms - js_calls_sample_time_ms_;
js_calls_counter_ = counter;
js_calls_sample_time_ms_ = time_ms;
return time_delta_ms > 0 ? call_delta / time_delta_ms : 0;
}
void MemoryReducer::NotifyTimer(const Event& event) { void MemoryReducer::NotifyTimer(const Event& event) {
DCHECK_EQ(kTimer, event.type); DCHECK_EQ(kTimer, event.type);
DCHECK_EQ(kWait, state_.action); DCHECK_EQ(kWait, state_.action);
...@@ -196,8 +184,6 @@ MemoryReducer::State MemoryReducer::Step(const State& state, ...@@ -196,8 +184,6 @@ MemoryReducer::State MemoryReducer::Step(const State& state,
void MemoryReducer::ScheduleTimer(double time_ms, double delay_ms) { void MemoryReducer::ScheduleTimer(double time_ms, double delay_ms) {
DCHECK(delay_ms > 0); DCHECK(delay_ms > 0);
// Record the time and the js call counter.
SampleAndGetJsCallsPerMs(time_ms);
// Leave some room for precision error in task scheduler. // Leave some room for precision error in task scheduler.
const double kSlackMs = 100; const double kSlackMs = 100;
v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap()->isolate()); v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap()->isolate());
......
...@@ -149,9 +149,6 @@ class V8_EXPORT_PRIVATE MemoryReducer { ...@@ -149,9 +149,6 @@ class V8_EXPORT_PRIVATE MemoryReducer {
static bool WatchdogGC(const State& state, const Event& event); static bool WatchdogGC(const State& state, const Event& event);
// Returns the rate of JS calls initiated from the API.
double SampleAndGetJsCallsPerMs(double time_ms);
Heap* heap_; Heap* heap_;
State state_; State state_;
unsigned int js_calls_counter_; unsigned int js_calls_counter_;
......
...@@ -2120,7 +2120,6 @@ Isolate::Isolate(bool enable_serializer) ...@@ -2120,7 +2120,6 @@ Isolate::Isolate(bool enable_serializer)
optimizing_compile_dispatcher_(NULL), optimizing_compile_dispatcher_(NULL),
stress_deopt_count_(0), stress_deopt_count_(0),
next_optimization_id_(0), next_optimization_id_(0),
js_calls_from_api_counter_(0),
#if TRACE_MAPS #if TRACE_MAPS
next_unique_sfi_id_(0), next_unique_sfi_id_(0),
#endif #endif
......
...@@ -1073,12 +1073,6 @@ class Isolate { ...@@ -1073,12 +1073,6 @@ class Isolate {
return id; return id;
} }
void IncrementJsCallsFromApiCounter() { ++js_calls_from_api_counter_; }
unsigned int js_calls_from_api_counter() {
return js_calls_from_api_counter_;
}
// Get (and lazily initialize) the registry for per-isolate symbols. // Get (and lazily initialize) the registry for per-isolate symbols.
Handle<JSObject> GetSymbolRegistry(); Handle<JSObject> GetSymbolRegistry();
...@@ -1416,9 +1410,6 @@ class Isolate { ...@@ -1416,9 +1410,6 @@ class Isolate {
int next_optimization_id_; int next_optimization_id_;
// Counts javascript calls from the API. Wraps around on overflow.
unsigned int js_calls_from_api_counter_;
#if TRACE_MAPS #if TRACE_MAPS
int next_unique_sfi_id_; int next_unique_sfi_id_;
#endif #endif
......
...@@ -6408,30 +6408,6 @@ TEST(Regress519319) { ...@@ -6408,30 +6408,6 @@ TEST(Regress519319) {
} }
HEAP_TEST(TestMemoryReducerSampleJsCalls) {
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
Heap* heap = CcTest::heap();
Isolate* isolate = CcTest::i_isolate();
MemoryReducer* memory_reducer = heap->memory_reducer_;
memory_reducer->SampleAndGetJsCallsPerMs(0);
isolate->IncrementJsCallsFromApiCounter();
isolate->IncrementJsCallsFromApiCounter();
isolate->IncrementJsCallsFromApiCounter();
double calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(1);
CheckDoubleEquals(3, calls_per_ms);
calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(2);
CheckDoubleEquals(0, calls_per_ms);
isolate->IncrementJsCallsFromApiCounter();
isolate->IncrementJsCallsFromApiCounter();
isolate->IncrementJsCallsFromApiCounter();
isolate->IncrementJsCallsFromApiCounter();
calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4);
CheckDoubleEquals(2, calls_per_ms);
}
HEAP_TEST(Regress587004) { HEAP_TEST(Regress587004) {
FLAG_concurrent_sweeping = false; FLAG_concurrent_sweeping = false;
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
......
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