Throttle resource message requests during user interaction
commitacfb4199abf841a1577c3968579c43b0232a53b7
authorjdduke <jdduke@chromium.org>
Thu, 5 Feb 2015 03:47:15 +0000 (4 19:47 -0800)
committerCommit bot <commit-bot@chromium.org>
Thu, 5 Feb 2015 03:48:16 +0000 (5 03:48 +0000)
treed1152d77cb4c20309f44895fbde784ffdba41199
parent072ef39848b879faa486c76568c1b023524f0fb3
Throttle resource message requests during user interaction

Resource message requests can be relatively expensive, particularly in
the induced work on the browser IO thread. Currently, there is no bound
on the rate with which such requests are dispatched from the renderer.
This leads to situations where the browser IO thread is flooded with
requests, potentially causing scroll jank and otherwise undesirable
stalls in the browser pipeline.

Introduce a ResourceMessageThrottler which intercepts and defers a given
resource message stream, depending on the state of the RendererScheduler.
When the RendererScheduler indicates that high priority work is
imminent/likely, requests will be throttled according to a configurable
dispatch rate.

Hook this throttling mechanism up to the ResourceDispatcher, limiting
the number of resource message requests/second during user interaction
to 180 (3 per frame at 60 fps) on Android, and 480 on desktop.

See goo.gl/H42AgQ for more design details.

BUG=440037,402136

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

Cr-Commit-Position: refs/heads/master@{#314739}
16 files changed:
content/child/resource_dispatcher.h
content/content_renderer.gypi
content/content_tests.gypi
content/renderer/render_thread_impl.cc
content/renderer/render_thread_impl.h
content/renderer/scheduler/null_renderer_scheduler.cc
content/renderer/scheduler/null_renderer_scheduler.h
content/renderer/scheduler/renderer_scheduler.h
content/renderer/scheduler/renderer_scheduler_impl.cc
content/renderer/scheduler/renderer_scheduler_impl.h
content/renderer/scheduler/renderer_scheduler_impl_unittest.cc
content/renderer/scheduler/resource_dispatch_throttler.cc [new file with mode: 0644]
content/renderer/scheduler/resource_dispatch_throttler.h [new file with mode: 0644]
content/renderer/scheduler/resource_dispatch_throttler_unittest.cc [new file with mode: 0644]
content/test/fake_renderer_scheduler.cc
content/test/fake_renderer_scheduler.h