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

Issue 637303003: content: Add task queue manager (Closed)

Created:
6 years, 2 months ago by Sami
Modified:
6 years, 1 month ago
CC:
chromium-reviews, danakj, darin (slow to review), darin-cc_chromium.org, jam, mkwst+moarreviews-renderer_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

content: Add task queue manager This patch introduces a task queue manager class which provides two main pieces of functionality: 1. An arbitrary number of incoming task queues. 2. A selector interface which allows an outside agent choose the next task queue to be serviced. This allows the selector implementation to dynamically prioritize between pending tasks in the different queues. Actual task running is accomplished by posting a task to a separate task runner (usually the main MessageLoop) so that the task queues can coexist with other work being done on the same thread. This class will be used by the Blink scheduler. Design doc: https://docs.google.com/a/chromium.org/document/d/16f_RIhZa47uEK_OdtTgzWdRU0RFMTQWMpEWyWXIpXUo/edit#heading=h.srz53flt1rrp BUG=391005 Committed: https://crrev.com/1161fca345efbace93bfda2a874f7dde3f3e5381 Cr-Commit-Position: refs/heads/master@{#300870}

Patch Set 1 #

Patch Set 2 : Add scheduling. #

Patch Set 3 : First stab at blink integration. #

Total comments: 12

Patch Set 4 : Refactor based on discussions. #

Patch Set 5 : API updates. #

Patch Set 6 : Move TaskQueueManager to base. #

Patch Set 7 : Strip out everything else than TaskQueueManager. Added tests. #

Total comments: 25

Patch Set 8 : Review comments. #

Total comments: 2

Patch Set 9 : More review comments. #

Patch Set 10 : Disable task runners after shutdown. #

Patch Set 11 : Back to content. #

Total comments: 12

Patch Set 12 : Rebased. #

Patch Set 13 : Jochen's comments. #

Total comments: 23

Patch Set 14 : Rebased. No more virtual + override. #

Patch Set 15 : Carlos's comments. #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+748 lines, -0 lines) Patch
M content/content_renderer.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +3 lines, -0 lines 0 comments Download
M content/content_tests.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -0 lines 0 comments Download
A content/renderer/scheduler/task_queue_manager.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +123 lines, -0 lines 2 comments Download
A content/renderer/scheduler/task_queue_manager.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +253 lines, -0 lines 0 comments Download
A content/renderer/scheduler/task_queue_manager_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +331 lines, -0 lines 0 comments Download
A content/renderer/scheduler/task_queue_selector.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +37 lines, -0 lines 0 comments Download

Messages

Total messages: 60 (11 generated)
Sami
Here's what a Chromium-side layered task queue manager could look like. The Blink integration still ...
6 years, 2 months ago (2014-10-10 17:09:43 UTC) #2
Sami
It's still also worth thinking about whether it would be simpler to do all of ...
6 years, 2 months ago (2014-10-10 17:34:58 UTC) #3
alexclarke
https://codereview.chromium.org/637303003/diff/120001/content/renderer/renderer_blink_platform_impl.h File content/renderer/renderer_blink_platform_impl.h (right): https://codereview.chromium.org/637303003/diff/120001/content/renderer/renderer_blink_platform_impl.h#newcode62 content/renderer/renderer_blink_platform_impl.h:62: virtual void callOnMainThread(void (*func)(void*), void* context); Personally I'm OK ...
6 years, 2 months ago (2014-10-13 10:06:23 UTC) #5
Sami
https://codereview.chromium.org/637303003/diff/120001/content/renderer/renderer_blink_platform_impl.h File content/renderer/renderer_blink_platform_impl.h (right): https://codereview.chromium.org/637303003/diff/120001/content/renderer/renderer_blink_platform_impl.h#newcode62 content/renderer/renderer_blink_platform_impl.h:62: virtual void callOnMainThread(void (*func)(void*), void* context); On 2014/10/13 10:06:22, ...
6 years, 2 months ago (2014-10-13 18:16:22 UTC) #6
Sami
Hey Darin, since it sounded like you were interested in all of this, would you ...
6 years, 2 months ago (2014-10-14 19:25:34 UTC) #8
picksi1
https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.cc File base/task/task_queue_manager.cc (right): https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.cc#newcode43 base/task/task_queue_manager.cc:43: } Should auto_pump be called pump_when_empty? https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.cc#newcode66 base/task/task_queue_manager.cc:66: scheduler_->RegisterWorkQueues(work_queues); ...
6 years, 2 months ago (2014-10-15 09:07:39 UTC) #9
alexclarke
https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.h File base/task/task_queue_manager.h (right): https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.h#newcode51 base/task/task_queue_manager.h:51: void SetAutoPump(size_t queue_index, bool auto_pump); I suspect this method ...
6 years, 2 months ago (2014-10-15 09:48:59 UTC) #10
petrcermak
https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.cc File base/task/task_queue_manager.cc (right): https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.cc#newcode84 base/task/task_queue_manager.cc:84: return !queue->incoming_queue.empty(); Shouldn't this be "return queue->auto_pump && !queue->incoming_queue.empty();"? ...
6 years, 2 months ago (2014-10-15 10:05:40 UTC) #11
alexclarke
https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.cc File base/task/task_queue_manager.cc (right): https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.cc#newcode84 base/task/task_queue_manager.cc:84: return !queue->incoming_queue.empty(); On 2014/10/15 10:05:40, petrcermak wrote: > Shouldn't ...
6 years, 2 months ago (2014-10-15 10:09:14 UTC) #12
petrcermak
https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.cc File base/task/task_queue_manager.cc (right): https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.cc#newcode84 base/task/task_queue_manager.cc:84: return !queue->incoming_queue.empty(); On 2014/10/15 10:09:14, alexclarke wrote: > On ...
6 years, 2 months ago (2014-10-15 10:13:05 UTC) #13
Sami
Thanks for all the comments! https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.cc File base/task/task_queue_manager.cc (right): https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.cc#newcode43 base/task/task_queue_manager.cc:43: } On 2014/10/15 09:07:38, ...
6 years, 2 months ago (2014-10-15 12:05:24 UTC) #14
rmcilroy
Nice, I like this overall. A couple of comments. https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.cc File base/task/task_queue_manager.cc (right): https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.cc#newcode134 base/task/task_queue_manager.cc:134: ...
6 years, 2 months ago (2014-10-15 13:02:45 UTC) #15
Sami
https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.cc File base/task/task_queue_manager.cc (right): https://codereview.chromium.org/637303003/diff/430001/base/task/task_queue_manager.cc#newcode134 base/task/task_queue_manager.cc:134: } On 2014/10/15 13:02:45, rmcilroy wrote: > On 2014/10/15 ...
6 years, 2 months ago (2014-10-15 14:34:30 UTC) #16
Sami
I'm going out on a limb and assuming Darin is oversubscribed. Dana, wanna have a ...
6 years, 2 months ago (2014-10-15 14:39:28 UTC) #18
Sami
Ping? I'm scaring off all reviewers with this patch. Not a great sign.
6 years, 2 months ago (2014-10-16 17:30:00 UTC) #19
danakj
On 2014/10/16 17:30:00, Sami wrote: > Ping? I'm scaring off all reviewers with this patch. ...
6 years, 2 months ago (2014-10-16 17:31:04 UTC) #20
Sami
On 2014/10/16 17:31:04, danakj wrote: > Can I ask why this should live in base/ ...
6 years, 2 months ago (2014-10-17 09:58:34 UTC) #21
danakj
Let's move it to base if it makes sense in the future. We should avoid ...
6 years, 2 months ago (2014-10-17 15:26:36 UTC) #22
Sami
On 2014/10/17 15:26:36, danakj wrote: > Let's move it to base if it makes sense ...
6 years, 2 months ago (2014-10-17 16:16:39 UTC) #24
jochen (gone - plz use gerrit)
adding danakj back in. I don't think it makes sense to move this to content/ ...
6 years, 2 months ago (2014-10-20 13:35:31 UTC) #26
jochen (gone - plz use gerrit)
also, I'd prefer if somebody with more background on our message loops would review this. ...
6 years, 2 months ago (2014-10-20 13:36:44 UTC) #27
danakj
On Mon, Oct 20, 2014 at 9:35 AM, <jochen@chromium.org> wrote: > adding danakj back in. ...
6 years, 2 months ago (2014-10-20 14:38:10 UTC) #28
jochen (gone - plz use gerrit)
we could create such a place, but it's essentially a fancy thread pool, so I ...
6 years, 2 months ago (2014-10-20 14:48:26 UTC) #29
danakj
On Mon, Oct 20, 2014 at 10:48 AM, <jochen@chromium.org> wrote: > we could create such ...
6 years, 2 months ago (2014-10-20 14:51:49 UTC) #30
jochen (gone - plz use gerrit)
On 2014/10/20 at 14:51:49, danakj wrote: > On Mon, Oct 20, 2014 at 10:48 AM, ...
6 years, 2 months ago (2014-10-20 14:57:40 UTC) #32
danakj
On Mon, Oct 20, 2014 at 10:57 AM, <jochen@chromium.org> wrote: > On 2014/10/20 at 14:51:49, ...
6 years, 2 months ago (2014-10-20 14:59:45 UTC) #33
jochen (gone - plz use gerrit)
no, because cc/ is one component. mojo and content are two different projects
6 years, 2 months ago (2014-10-20 15:00:46 UTC) #34
Sami
Thanks for taking a look Jochen. I'm happy to put this where ever the code ...
6 years, 2 months ago (2014-10-20 15:01:39 UTC) #35
danakj
On Mon, Oct 20, 2014 at 11:00 AM, <jochen@chromium.org> wrote: > no, because cc/ is ...
6 years, 2 months ago (2014-10-20 15:04:12 UTC) #36
jochen (gone - plz use gerrit)
it will be used in //mojo/services/html_viewer I'd recommend jar@ for message loop
6 years, 2 months ago (2014-10-20 15:06:07 UTC) #37
Sami
On 2014/10/20 15:06:07, jochen wrote: > it will be used in //mojo/services/html_viewer > > I'd ...
6 years, 2 months ago (2014-10-20 15:16:00 UTC) #39
Sami
https://codereview.chromium.org/637303003/diff/510001/content/renderer/scheduler/task_queue_manager.h File content/renderer/scheduler/task_queue_manager.h (right): https://codereview.chromium.org/637303003/diff/510001/content/renderer/scheduler/task_queue_manager.h#newcode70 content/renderer/scheduler/task_queue_manager.h:70: class TaskRunner : public base::SingleThreadTaskRunner { On 2014/10/20 13:35:31, ...
6 years, 2 months ago (2014-10-20 15:29:57 UTC) #40
cpu_(ooo_6.6-7.5)
Overall I think this is acceptable. location: I argue we should bake it in content, ...
6 years, 2 months ago (2014-10-20 19:35:29 UTC) #41
cpu_(ooo_6.6-7.5)
https://codereview.chromium.org/637303003/diff/550001/content/renderer/scheduler/task_queue_manager.cc File content/renderer/scheduler/task_queue_manager.cc (right): https://codereview.chromium.org/637303003/diff/550001/content/renderer/scheduler/task_queue_manager.cc#newcode32 content/renderer/scheduler/task_queue_manager.cc:32: base::WeakPtr<TaskQueueManager> task_queue_manager_; why is this weak? https://codereview.chromium.org/637303003/diff/550001/content/renderer/scheduler/task_queue_manager.cc#newcode69 content/renderer/scheduler/task_queue_manager.cc:69: } ...
6 years, 2 months ago (2014-10-20 20:00:10 UTC) #42
Sami
On 2014/10/20 19:35:29, cpu wrote: > Overall I think this is acceptable. Thanks for having ...
6 years, 2 months ago (2014-10-21 10:32:54 UTC) #43
cpu_(ooo_6.6-7.5)
https://codereview.chromium.org/637303003/diff/550001/content/renderer/scheduler/task_queue_manager.cc File content/renderer/scheduler/task_queue_manager.cc (right): https://codereview.chromium.org/637303003/diff/550001/content/renderer/scheduler/task_queue_manager.cc#newcode32 content/renderer/scheduler/task_queue_manager.cc:32: base::WeakPtr<TaskQueueManager> task_queue_manager_; On 2014/10/21 10:32:54, Sami wrote: > On ...
6 years, 2 months ago (2014-10-21 19:46:07 UTC) #44
Sami
Thanks for the review! https://codereview.chromium.org/637303003/diff/550001/content/renderer/scheduler/task_queue_manager.cc File content/renderer/scheduler/task_queue_manager.cc (right): https://codereview.chromium.org/637303003/diff/550001/content/renderer/scheduler/task_queue_manager.cc#newcode32 content/renderer/scheduler/task_queue_manager.cc:32: base::WeakPtr<TaskQueueManager> task_queue_manager_; On 2014/10/21 19:46:07, ...
6 years, 2 months ago (2014-10-22 12:09:08 UTC) #45
cpu_(ooo_6.6-7.5)
lgtm on my side.
6 years, 2 months ago (2014-10-22 23:27:04 UTC) #46
jochen (gone - plz use gerrit)
lgtm
6 years, 2 months ago (2014-10-23 09:37:27 UTC) #47
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/637303003/590001
6 years, 2 months ago (2014-10-23 09:44:49 UTC) #49
commit-bot: I haz the power
Try jobs failed on following builders: mac_chromium_rel on tryserver.chromium.mac (http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel/builds/5383)
6 years, 2 months ago (2014-10-23 11:17:01 UTC) #51
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/637303003/590001
6 years, 2 months ago (2014-10-23 11:26:11 UTC) #53
commit-bot: I haz the power
Committed patchset #15 (id:590001)
6 years, 2 months ago (2014-10-23 11:47:20 UTC) #54
commit-bot: I haz the power
Patchset 15 (id:??) landed as https://crrev.com/1161fca345efbace93bfda2a874f7dde3f3e5381 Cr-Commit-Position: refs/heads/master@{#300870}
6 years, 2 months ago (2014-10-23 11:48:03 UTC) #55
jar (doing other things)
https://codereview.chromium.org/637303003/diff/550001/content/renderer/scheduler/task_queue_manager.cc File content/renderer/scheduler/task_queue_manager.cc (right): https://codereview.chromium.org/637303003/diff/550001/content/renderer/scheduler/task_queue_manager.cc#newcode148 content/renderer/scheduler/task_queue_manager.cc:148: PostDoWorkOnMainRunner(); In general, it is a bad idea to ...
6 years, 1 month ago (2014-10-28 22:33:41 UTC) #56
Sami
https://codereview.chromium.org/637303003/diff/550001/content/renderer/scheduler/task_queue_manager.cc File content/renderer/scheduler/task_queue_manager.cc (right): https://codereview.chromium.org/637303003/diff/550001/content/renderer/scheduler/task_queue_manager.cc#newcode148 content/renderer/scheduler/task_queue_manager.cc:148: PostDoWorkOnMainRunner(); On 2014/10/28 22:33:41, jar wrote: > In general, ...
6 years, 1 month ago (2014-10-29 11:36:19 UTC) #57
Sami
https://codereview.chromium.org/637303003/diff/550001/content/renderer/scheduler/task_queue_manager.cc File content/renderer/scheduler/task_queue_manager.cc (right): https://codereview.chromium.org/637303003/diff/550001/content/renderer/scheduler/task_queue_manager.cc#newcode148 content/renderer/scheduler/task_queue_manager.cc:148: PostDoWorkOnMainRunner(); On 2014/10/29 11:36:19, Sami wrote: > On 2014/10/28 ...
6 years, 1 month ago (2014-10-29 12:49:08 UTC) #58
jar (doing other things)
https://codereview.chromium.org/637303003/diff/550001/content/renderer/scheduler/task_queue_manager.cc File content/renderer/scheduler/task_queue_manager.cc (right): https://codereview.chromium.org/637303003/diff/550001/content/renderer/scheduler/task_queue_manager.cc#newcode148 content/renderer/scheduler/task_queue_manager.cc:148: PostDoWorkOnMainRunner(); On 2014/10/29 12:49:08, Sami wrote: > On 2014/10/29 ...
6 years, 1 month ago (2014-10-29 21:14:07 UTC) #59
Sami
6 years, 1 month ago (2014-10-30 10:43:00 UTC) #60
Message was sent while issue was closed.
https://codereview.chromium.org/637303003/diff/550001/content/renderer/schedu...
File content/renderer/scheduler/task_queue_manager.cc (right):

https://codereview.chromium.org/637303003/diff/550001/content/renderer/schedu...
content/renderer/scheduler/task_queue_manager.cc:148: PostDoWorkOnMainRunner();
On 2014/10/29 21:14:07, jar wrote:
> On 2014/10/29 12:49:08, Sami wrote:
> > On 2014/10/29 11:36:19, Sami wrote:
> > > On 2014/10/28 22:33:41, jar wrote:
> > > > In general, it is a bad idea to do much work while a lock is held, and
> more
> > > > often than not, an error to call out to an arbitrary function while
> holding
> > a
> > > > lock.
> > > > 
> > > > Is there a reason why you need the lock held when calling this function.
> > > 
> > > You're right, PostDoWorkOnMainRunner() doesn't need any protection from
the
> > > lock. I'll write a CL to move it outside the lock scope.
> > 
> > On further reflection, we do need to hold the lock because it prevents the
> > TaskQueueManager from getting deleted from under us as we're posting the
task.
> > This code has been refactored since this patch to make the locking
> dependencies
> > more explicit.
> 
> Can you point to how the lock acquisition precludes destruction?
> 
> If that were the only thing blocking destruction... then couldn't destruction
> happen between line 145 and 146??  ...and wouldn't that cause problems on line
> 146 when trying to lock?

The locking wasn't quite right in this version of the patch. See here:
https://code.google.com/p/chromium/codesearch#chromium/src/content/renderer/s...

Each queue is notified about TQM going away in its destructor. This notification
is protected by the same lock that is held while PostDoWorkOnMainRunner() is
called.

https://codereview.chromium.org/637303003/diff/590001/content/renderer/schedu...
File content/renderer/scheduler/task_queue_manager.h (right):

https://codereview.chromium.org/637303003/diff/590001/content/renderer/schedu...
content/renderer/scheduler/task_queue_manager.h:105: internal::TaskQueue*
Queue(size_t queue_index) const;
On 2014/10/29 21:14:07, jar wrote:
> I found this declaration, and its use, but didn't see its implementation. 
Where
> is it?  (I doesn't even show in the unified diff for the patch).

It's at line 113 of task_queue_manager.cc in this patch set.

Powered by Google App Engine
This is Rietveld 408576698