Run task queue manager work in batches
commita11ff40fc19b20b4b47f6875e81859978be3be84
authorskyostil <skyostil@chromium.org>
Tue, 3 Feb 2015 17:55:46 +0000 (3 09:55 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 3 Feb 2015 17:56:56 +0000 (3 17:56 +0000)
tree1015d8e87c69d8ab3194693c711a4d64774c9945
parentad46c41ecb9cb2afb6a7e535e36679d84691f70e
Run task queue manager work in batches

This patch lets the task queue manager run more than one posted task
per invocation. This helps reduce the overhead of yielding to and from
the main message loop and can speed up cases where tasks are posted
very frequently. One example is indexeddb, where some operations such as
index building can result in 2500 posted tasks/s (Nexus 7).

This patch also adds accounting for the desired run time of the next
pending delayed task. This information is used to break out of a work
batch if a delayed task should be run instead. Doing this avoids adding
extra delay to delayed tasks.

A potential downside of this change is that it can penalize work that
runs on the message loop without going through the task queue manager.
Based on performance tests[1], almost all tasks on the renderer main
thread are already getting executed by the task queue manager, so I
believe this change shouldn't cause a regression.

Note that this version of the patch still uses a batch size of 1 while
we investigate some mac test failures triggered by larger batch sizes.

[1] https://docs.google.com/a/chromium.org/spreadsheets/d/1IJZpBabW1pr4fb2T8BlkleHcOvHYrjvmCx_dLesxfMA/edit#gid=1492760051

BUG=444764,451593,453898

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

Cr-Commit-Position: refs/heads/master@{#314364}
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/task_queue_manager.cc
content/renderer/scheduler/task_queue_manager.h
content/renderer/scheduler/task_queue_manager_unittest.cc
tools/ubsan/blacklist.txt