Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(953)

Issue 1008693004: Handle delayed tasks more natively in the scheduler (Closed)

Created:
5 years, 9 months ago by alex clarke (OOO till 29th)
Modified:
5 years, 9 months ago
Reviewers:
brianderson, rmcilroy, Sami
CC:
chromium-reviews, mlamouri+watch-content_chromium.org, jam, darin-cc_chromium.org, mkwst+moarreviews-renderer_chromium.org, cc-bugs_chromium.org, scheduler-bugs_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

The TaskQueueManager's internal::TaskQueue now has a priority queue of delayed tasks. When these tasks are ready to execute, they are enqueued on the normal task queue. The main motivation for doing this is so that delayed tasks posted from Blink can be properly flushed when the scheduler shuts down. This is important because we would otherwise risk leaving tasks allocated on the Blink Heap that has gone away. Benchmarking suggests that the overhead of this approach is actually a bit lower than posting to the base MessageLoop when posting lots of delayed tasks. BUG=463143 Committed: https://crrev.com/546ca22ac2fd1bfddcb674813c7777041508dc27 Cr-Commit-Position: refs/heads/master@{#321183}

Patch Set 1 #

Patch Set 2 : Rebase #

Patch Set 3 : Sami's Suggestions #

Total comments: 24

Patch Set 4 : A second round of feedback. #

Patch Set 5 : Work around problem with non-auto pump queues and delayed tasks #

Total comments: 15

Patch Set 6 : Responding to yet more feedback. Also removed some boilerplate calls to AppendQueueToService #

Total comments: 13

Patch Set 7 : Responding to feedback again #

Total comments: 3

Patch Set 8 : Fixed the problem with the lack of std::min and added a test. #

Patch Set 9 : fix compile issue #

Patch Set 10 : Fix bug with AutomaticSelectorForTest and multiple queues #

Unified diffs Side-by-side diffs Delta from patch set Stats (+498 lines, -247 lines) Patch
M cc/test/ordered_simple_task_runner.h View 1 chunk +1 line, -0 lines 0 comments Download
M cc/test/ordered_simple_task_runner.cc View 1 chunk +4 lines, -0 lines 0 comments Download
M cc/test/test_now_source.h View 1 2 2 chunks +3 lines, -0 lines 0 comments Download
M cc/test/test_now_source.cc View 1 2 2 chunks +8 lines, -3 lines 0 comments Download
M content/renderer/scheduler/task_queue_manager.h View 1 2 3 4 5 6 4 chunks +8 lines, -4 lines 0 comments Download
M content/renderer/scheduler/task_queue_manager.cc View 1 2 3 4 5 6 7 16 chunks +141 lines, -59 lines 0 comments Download
M content/renderer/scheduler/task_queue_manager_unittest.cc View 1 2 3 4 5 6 7 8 9 39 chunks +333 lines, -181 lines 0 comments Download

Messages

Total messages: 36 (11 generated)
alex clarke (OOO till 29th)
5 years, 9 months ago (2015-03-13 16:21:07 UTC) #1
alex clarke (OOO till 29th)
5 years, 9 months ago (2015-03-13 16:23:31 UTC) #3
alex clarke (OOO till 29th)
+brianderson@ for the cc/test/ordered_simple_task_runner.h &.cc change +sami for the other bits
5 years, 9 months ago (2015-03-13 16:25:08 UTC) #5
brianderson
lgtm!
5 years, 9 months ago (2015-03-13 17:06:43 UTC) #6
alex clarke (OOO till 29th)
Sami I've followed the suggestions from https://codereview.chromium.org/962273002/ in here.
5 years, 9 months ago (2015-03-17 12:39:17 UTC) #7
Sami
Thanks Alex. https://codereview.chromium.org/1008693004/diff/40001/content/renderer/scheduler/task_queue_manager.cc File content/renderer/scheduler/task_queue_manager.cc (right): https://codereview.chromium.org/1008693004/diff/40001/content/renderer/scheduler/task_queue_manager.cc#newcode24 content/renderer/scheduler/task_queue_manager.cc:24: class LazyNow { Neat helper! https://codereview.chromium.org/1008693004/diff/40001/content/renderer/scheduler/task_queue_manager.cc#newcode93 content/renderer/scheduler/task_queue_manager.cc:93: ...
5 years, 9 months ago (2015-03-17 15:54:45 UTC) #8
alex clarke (OOO till 29th)
https://codereview.chromium.org/1008693004/diff/40001/content/renderer/scheduler/task_queue_manager.cc File content/renderer/scheduler/task_queue_manager.cc (right): https://codereview.chromium.org/1008693004/diff/40001/content/renderer/scheduler/task_queue_manager.cc#newcode24 content/renderer/scheduler/task_queue_manager.cc:24: class LazyNow { On 2015/03/17 15:54:45, Sami wrote: > ...
5 years, 9 months ago (2015-03-17 16:53:07 UTC) #10
alex clarke (OOO till 29th)
As discussed offline I've worked around a problem with non-auto pump queues and delayed tasks. ...
5 years, 9 months ago (2015-03-17 17:59:19 UTC) #11
Sami
Thanks, looking pretty good now I think. https://codereview.chromium.org/1008693004/diff/80001/content/renderer/scheduler/task_queue_manager.cc File content/renderer/scheduler/task_queue_manager.cc (right): https://codereview.chromium.org/1008693004/diff/80001/content/renderer/scheduler/task_queue_manager.cc#newcode104 content/renderer/scheduler/task_queue_manager.cc:104: // Enqueues ...
5 years, 9 months ago (2015-03-17 18:40:03 UTC) #12
rmcilroy
This looks pretty good to me. I was originally a bit worried about delayed tasks ...
5 years, 9 months ago (2015-03-17 19:06:54 UTC) #13
rmcilroy
This looks pretty good to me. I was originally a bit worried about delayed tasks ...
5 years, 9 months ago (2015-03-17 19:06:56 UTC) #14
alex clarke (OOO till 29th)
https://codereview.chromium.org/1008693004/diff/80001/content/renderer/scheduler/task_queue_manager.cc File content/renderer/scheduler/task_queue_manager.cc (right): https://codereview.chromium.org/1008693004/diff/80001/content/renderer/scheduler/task_queue_manager.cc#newcode104 content/renderer/scheduler/task_queue_manager.cc:104: // Enqueues any delayed tasks which should be run ...
5 years, 9 months ago (2015-03-18 10:49:08 UTC) #15
Sami
Awesome, I think the delayed task logic is now sound. Just one more nit to ...
5 years, 9 months ago (2015-03-18 11:13:21 UTC) #16
rmcilroy
https://codereview.chromium.org/1008693004/diff/80001/content/renderer/scheduler/task_queue_manager.cc File content/renderer/scheduler/task_queue_manager.cc (right): https://codereview.chromium.org/1008693004/diff/80001/content/renderer/scheduler/task_queue_manager.cc#newcode218 content/renderer/scheduler/task_queue_manager.cc:218: void TaskQueue::KickDelayedTasks() { On 2015/03/18 10:49:07, alexclarke1 wrote: > ...
5 years, 9 months ago (2015-03-18 11:23:29 UTC) #17
alex clarke (OOO till 29th)
https://codereview.chromium.org/1008693004/diff/100001/content/renderer/scheduler/task_queue_manager.cc File content/renderer/scheduler/task_queue_manager.cc (right): https://codereview.chromium.org/1008693004/diff/100001/content/renderer/scheduler/task_queue_manager.cc#newcode133 content/renderer/scheduler/task_queue_manager.cc:133: base::ThreadChecker main_thread_checker_; On 2015/03/18 11:13:21, Sami wrote: > nit: ...
5 years, 9 months ago (2015-03-18 12:15:10 UTC) #18
Sami
https://codereview.chromium.org/1008693004/diff/120001/content/renderer/scheduler/task_queue_manager.cc File content/renderer/scheduler/task_queue_manager.cc (right): https://codereview.chromium.org/1008693004/diff/120001/content/renderer/scheduler/task_queue_manager.cc#newcode289 content/renderer/scheduler/task_queue_manager.cc:289: *next_pending_delayed_task = delayed_task_queue_.top().delayed_run_time; It's not obvious from the function's ...
5 years, 9 months ago (2015-03-18 12:26:43 UTC) #19
alex clarke (OOO till 29th)
https://codereview.chromium.org/1008693004/diff/120001/content/renderer/scheduler/task_queue_manager.cc File content/renderer/scheduler/task_queue_manager.cc (right): https://codereview.chromium.org/1008693004/diff/120001/content/renderer/scheduler/task_queue_manager.cc#newcode289 content/renderer/scheduler/task_queue_manager.cc:289: *next_pending_delayed_task = delayed_task_queue_.top().delayed_run_time; On 2015/03/18 12:26:43, Sami wrote: > ...
5 years, 9 months ago (2015-03-18 12:38:32 UTC) #20
Sami
lgtm, thank you Alex!
5 years, 9 months ago (2015-03-18 15:44:28 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1008693004/140001
5 years, 9 months ago (2015-03-18 16:07:01 UTC) #24
commit-bot: I haz the power
Try jobs failed on following builders: android_compile_rel on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/android_compile_rel/builds/25790)
5 years, 9 months ago (2015-03-18 16:29:05 UTC) #26
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1008693004/160001
5 years, 9 months ago (2015-03-18 16:34:05 UTC) #29
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_rel_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_rel_ng/builds/44692)
5 years, 9 months ago (2015-03-18 17:50:52 UTC) #31
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1008693004/180001
5 years, 9 months ago (2015-03-18 18:01:32 UTC) #34
commit-bot: I haz the power
Committed patchset #10 (id:180001)
5 years, 9 months ago (2015-03-18 19:07:12 UTC) #35
commit-bot: I haz the power
5 years, 9 months ago (2015-03-18 19:07:50 UTC) #36
Message was sent while issue was closed.
Patchset 10 (id:??) landed as
https://crrev.com/546ca22ac2fd1bfddcb674813c7777041508dc27
Cr-Commit-Position: refs/heads/master@{#321183}

Powered by Google App Engine
This is Rietveld 408576698