Commit 1393c4a9 authored by ulan@chromium.org's avatar ulan@chromium.org

Provide a hint for the idle notification handler.

The IdleNotification() function accepts an optional hint argument since V8 3.8.1 (rolled in r114984). 

This argument roughly specifies the expected duration of the idle pause and thus defines the amount of work to be done in the function. There is no guarantee that the actual work will match the hint though.

This CL provides hints for idle notifications sent from the foreground tab depending on the idle timer delay. This somewhat reduces idle notification pauses at the beginning of "idleness" period.

Review URL: http://codereview.chromium.org/9244007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120753 0039d316-1c4b-4281-b951-d872f2087c98
parent 9fc00f7c
...@@ -647,8 +647,11 @@ void RenderThreadImpl::IdleHandlerInForegroundTab() { ...@@ -647,8 +647,11 @@ void RenderThreadImpl::IdleHandlerInForegroundTab() {
} else { } else {
int cpu_usage = 0; int cpu_usage = 0;
Send(new ViewHostMsg_GetCPUUsage(&cpu_usage)); Send(new ViewHostMsg_GetCPUUsage(&cpu_usage));
// Idle notification hint roughly specifies the expected duration of the
// idle pause. We set it proportional to the idle timer delay.
int idle_hint = static_cast<int>(new_delay_ms / 10);
if (cpu_usage < kIdleCPUUsageThresholdInPercents && if (cpu_usage < kIdleCPUUsageThresholdInPercents &&
v8::V8::IdleNotification()) { v8::V8::IdleNotification(idle_hint)) {
// V8 finished collecting garbage. // V8 finished collecting garbage.
new_delay_ms = kLongIdleHandlerDelayMs; new_delay_ms = kLongIdleHandlerDelayMs;
} }
......
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