Reviewers: alex clarke
CL:
https://codereview.chromium.org/2786083005/Message:
I'm still chasing a couple of layout test failures but I think this is ready for
review. Alex, PTAL.
Description:
scheduler: Maintain a constant enqueue order for every task
The scheduler uses a monotonically increasing counter called enqueue
order for sorting tasks. This value was previously assigned at post
time for immediate tasks and at delay expiration time for delayed tasks.
Because expired delayed tasks get processed in a consistent order
(i.e., sorted by their delay) within a single task queue, but in
a random order between task queues, delayed tasks for the exact
same point in time posted two distinct task queues will run in a
random order w.r.t. each other. This in turn causes a problem in
virtual time scenarios where delayed tasks should behave
deterministically.
This patch fixes the problem by eliminating the two-phase assignment
of enqueue orders to delayed tasks. This was originally added to avoid
a flood of expired delayed tasks starving immediate work, but because
the selector now makes sure delayed work doesn't starve immediate work
and vice versa, this mechanism can be removed.
A side effect of this removal is that there is no longer a guarantee
that expired delayed tasks won't run before immediate tasks that were
posted later. Note that the base::TaskRunner doesn't offer this
guarantee either so it shouldn't be relied on.
BUG=696001,701223
Affected files (+254, -250 lines):
M content/browser/devtools/protocol/devtools_protocol_browsertest.cc
M third_party/WebKit/Source/platform/scheduler/base/enqueue_order.h
M third_party/WebKit/Source/platform/scheduler/base/enqueue_order.cc
M third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.h
M third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc
M third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h
M third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc
M third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_unittest.cc
M third_party/WebKit/Source/platform/scheduler/base/task_queue_selector.cc
M third_party/WebKit/Source/platform/scheduler/base/task_queue_selector_unittest.cc
M third_party/WebKit/Source/platform/scheduler/base/work_queue.h
M third_party/WebKit/Source/platform/scheduler/base/work_queue.cc
M third_party/WebKit/Source/platform/scheduler/base/work_queue_sets_unittest.cc
M third_party/WebKit/Source/platform/scheduler/base/work_queue_unittest.cc
M third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler_unittest.cc