Commit 3c9e8de5 authored by ulan's avatar ulan Committed by Commit bot

Fix idle notification for background tab.

The idle time handler should never return DONE or DO_SCAVENGE for
background tabs. Upon receiving DONE chrome will stop sending idle notifications.

BUG=chromium:515174
LOG=NO

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

Cr-Commit-Position: refs/heads/master@{#29926}
parent c1970988
...@@ -114,6 +114,10 @@ bool GCIdleTimeHandler::ShouldDoScavenge( ...@@ -114,6 +114,10 @@ bool GCIdleTimeHandler::ShouldDoScavenge(
size_t idle_time_in_ms, size_t new_space_size, size_t used_new_space_size, size_t idle_time_in_ms, size_t new_space_size, size_t used_new_space_size,
size_t scavenge_speed_in_bytes_per_ms, size_t scavenge_speed_in_bytes_per_ms,
size_t new_space_allocation_throughput_in_bytes_per_ms) { size_t new_space_allocation_throughput_in_bytes_per_ms) {
if (idle_time_in_ms >= kMinBackgroundIdleTime) {
// It is better to do full GC for the background tab.
return false;
}
size_t new_space_allocation_limit = size_t new_space_allocation_limit =
kMaxScheduledIdleTime * scavenge_speed_in_bytes_per_ms; kMaxScheduledIdleTime * scavenge_speed_in_bytes_per_ms;
...@@ -193,7 +197,10 @@ bool GCIdleTimeHandler::ShouldDoOverApproximateWeakClosure( ...@@ -193,7 +197,10 @@ bool GCIdleTimeHandler::ShouldDoOverApproximateWeakClosure(
} }
GCIdleTimeAction GCIdleTimeHandler::NothingOrDone() { GCIdleTimeAction GCIdleTimeHandler::NothingOrDone(double idle_time_in_ms) {
if (idle_time_in_ms >= kMinBackgroundIdleTime) {
return GCIdleTimeAction::Nothing();
}
if (idle_times_which_made_no_progress_ >= kMaxNoProgressIdleTimes) { if (idle_times_which_made_no_progress_ >= kMaxNoProgressIdleTimes) {
return GCIdleTimeAction::Done(); return GCIdleTimeAction::Done();
} else { } else {
...@@ -232,7 +239,7 @@ GCIdleTimeAction GCIdleTimeHandler::Compute(double idle_time_in_ms, ...@@ -232,7 +239,7 @@ GCIdleTimeAction GCIdleTimeHandler::Compute(double idle_time_in_ms,
// get the right idle signal. // get the right idle signal.
if (ShouldDoContextDisposalMarkCompact(heap_state.contexts_disposed, if (ShouldDoContextDisposalMarkCompact(heap_state.contexts_disposed,
heap_state.contexts_disposal_rate)) { heap_state.contexts_disposal_rate)) {
return NothingOrDone(); return NothingOrDone(idle_time_in_ms);
} }
if (ShouldDoScavenge( if (ShouldDoScavenge(
...@@ -247,7 +254,7 @@ GCIdleTimeAction GCIdleTimeHandler::Compute(double idle_time_in_ms, ...@@ -247,7 +254,7 @@ GCIdleTimeAction GCIdleTimeHandler::Compute(double idle_time_in_ms,
if (heap_state.sweeping_completed) { if (heap_state.sweeping_completed) {
return GCIdleTimeAction::FinalizeSweeping(); return GCIdleTimeAction::FinalizeSweeping();
} else { } else {
return NothingOrDone(); return NothingOrDone(idle_time_in_ms);
} }
} }
......
...@@ -198,7 +198,7 @@ class GCIdleTimeHandler { ...@@ -198,7 +198,7 @@ class GCIdleTimeHandler {
size_t new_space_allocation_throughput_in_bytes_per_ms); size_t new_space_allocation_throughput_in_bytes_per_ms);
private: private:
GCIdleTimeAction NothingOrDone(); GCIdleTimeAction NothingOrDone(double idle_time_in_ms);
// Idle notifications with no progress. // Idle notifications with no progress.
int idle_times_which_made_no_progress_; int idle_times_which_made_no_progress_;
......
...@@ -15434,6 +15434,9 @@ TEST(TestIdleNotification) { ...@@ -15434,6 +15434,9 @@ TEST(TestIdleNotification) {
(v8::base::TimeTicks::HighResolutionNow().ToInternalValue() / (v8::base::TimeTicks::HighResolutionNow().ToInternalValue() /
static_cast<double>(v8::base::Time::kMicrosecondsPerSecond)) + static_cast<double>(v8::base::Time::kMicrosecondsPerSecond)) +
IdlePauseInSeconds); IdlePauseInSeconds);
if (CcTest::heap()->mark_compact_collector()->sweeping_in_progress()) {
CcTest::heap()->mark_compact_collector()->EnsureSweepingCompleted();
}
} }
intptr_t final_size = CcTest::heap()->SizeOfObjects(); intptr_t final_size = CcTest::heap()->SizeOfObjects();
CHECK(finished); CHECK(finished);
......
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