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

Issue 1704113002: TaskScheduler [6] SchedulerWorkerThread (Closed)

Created:
4 years, 10 months ago by fdoray
Modified:
4 years, 8 months ago
Reviewers:
robliao, danakj, gab
CC:
chromium-reviews
Base URL:
https://chromium.googlesource.com/chromium/src.git@s_4_shutdown
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

TaskScheduler [6] SchedulerWorkerThread A SchedulerWorkerThread runs Tasks from Sequences returned by a custom callback. This change is a subset of https://codereview.chromium.org/1698183005/ BUG=553459 CC_FUTURE=chromium-reviews, vmpstr+watch@chromium.org Committed: https://crrev.com/93649e8fc3faf88cee5a9b03b67199c4bb614b1c Cr-Commit-Position: refs/heads/master@{#384441}

Patch Set 1 #

Total comments: 2

Patch Set 2 : rebase #

Patch Set 3 : rebase #

Patch Set 4 : rebase #

Total comments: 4

Patch Set 5 : CR from robliao #

Total comments: 93

Patch Set 6 : rebase #

Patch Set 7 : CR from gab #18 #

Total comments: 54

Patch Set 8 : CR robliao #22 #

Patch Set 9 : rebase #

Patch Set 10 : self-review #

Patch Set 11 : Experiment: State changes within the scope of a shared PQ Transaction. #

Patch Set 12 : self review #

Total comments: 9

Patch Set 13 : Experiment: Get work from a callback. #

Patch Set 14 : self review #

Total comments: 13

Patch Set 15 : CR robliao #31 #

Total comments: 22

Patch Set 16 : CR danakj #36 #

Patch Set 17 : format #

Patch Set 18 : add main entry callback #

Total comments: 27
Unified diffs Side-by-side diffs Delta from patch set Stats (+460 lines, -0 lines) Patch
M base/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 chunks +3 lines, -0 lines 0 comments Download
M base/base.gyp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +1 line, -0 lines 0 comments Download
M base/base.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +2 lines, -0 lines 0 comments Download
A base/task_scheduler/scheduler_worker_thread.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +109 lines, -0 lines 7 comments Download
A base/task_scheduler/scheduler_worker_thread.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +104 lines, -0 lines 6 comments Download
A base/task_scheduler/scheduler_worker_thread_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +241 lines, -0 lines 14 comments Download

Depends on Patchset:

Dependent Patchsets:

Messages

Total messages: 53 (16 generated)
fdoray
4 years, 10 months ago (2016-02-17 20:12:21 UTC) #1
robliao
https://codereview.chromium.org/1704113002/diff/1/base/task_scheduler/worker_thread.cc File base/task_scheduler/worker_thread.cc (right): https://codereview.chromium.org/1704113002/diff/1/base/task_scheduler/worker_thread.cc#newcode26 base/task_scheduler/worker_thread.cc:26: class SchedulerSingleThreadTaskRunner : public SingleThreadTaskRunner { Working through the ...
4 years, 9 months ago (2016-03-07 19:28:08 UTC) #6
gab
https://codereview.chromium.org/1704113002/diff/1/base/task_scheduler/worker_thread.cc File base/task_scheduler/worker_thread.cc (right): https://codereview.chromium.org/1704113002/diff/1/base/task_scheduler/worker_thread.cc#newcode26 base/task_scheduler/worker_thread.cc:26: class SchedulerSingleThreadTaskRunner : public SingleThreadTaskRunner { On 2016/03/07 19:28:08, ...
4 years, 9 months ago (2016-03-07 19:31:37 UTC) #7
fdoray
On 2016/03/07 19:28:08, robliao wrote: > https://codereview.chromium.org/1704113002/diff/1/base/task_scheduler/worker_thread.cc > File base/task_scheduler/worker_thread.cc (right): > > https://codereview.chromium.org/1704113002/diff/1/base/task_scheduler/worker_thread.cc#newcode26 > ...
4 years, 9 months ago (2016-03-07 19:33:40 UTC) #8
robliao
On 2016/03/07 19:33:40, fdoray wrote: > On 2016/03/07 19:28:08, robliao wrote: > > > https://codereview.chromium.org/1704113002/diff/1/base/task_scheduler/worker_thread.cc ...
4 years, 9 months ago (2016-03-07 19:36:30 UTC) #9
robliao
On 2016/03/07 19:36:30, robliao wrote: > On 2016/03/07 19:33:40, fdoray wrote: > > On 2016/03/07 ...
4 years, 9 months ago (2016-03-07 19:59:09 UTC) #10
fdoray
> An interesting consideration is what if someone creates a child task runner from > ...
4 years, 9 months ago (2016-03-07 20:12:10 UTC) #11
fdoray
I rebased this CL on the latest TaskTracker CL. Can you review it? Thanks.
4 years, 9 months ago (2016-03-08 00:46:08 UTC) #12
robliao
https://codereview.chromium.org/1704113002/diff/60001/base/task_scheduler/worker_thread.cc File base/task_scheduler/worker_thread.cc (right): https://codereview.chromium.org/1704113002/diff/60001/base/task_scheduler/worker_thread.cc#newcode210 base/task_scheduler/worker_thread.cc:210: bool sequence_is_single_threaded = false; For unit tests: If we're ...
4 years, 9 months ago (2016-03-09 15:41:12 UTC) #13
fdoray
https://codereview.chromium.org/1704113002/diff/60001/base/task_scheduler/worker_thread.cc File base/task_scheduler/worker_thread.cc (right): https://codereview.chromium.org/1704113002/diff/60001/base/task_scheduler/worker_thread.cc#newcode210 base/task_scheduler/worker_thread.cc:210: bool sequence_is_single_threaded = false; On 2016/03/09 15:41:12, robliao wrote: ...
4 years, 9 months ago (2016-03-14 20:46:35 UTC) #15
gab
Phew! Sorry for the delay, this is quite an advanced component, looks great overall! Mostly ...
4 years, 9 months ago (2016-03-21 19:11:55 UTC) #16
robliao
https://codereview.chromium.org/1704113002/diff/80001/base/task_scheduler/priority_queue.cc File base/task_scheduler/priority_queue.cc (right): https://codereview.chromium.org/1704113002/diff/80001/base/task_scheduler/priority_queue.cc#newcode19 base/task_scheduler/priority_queue.cc:19: : sequence(sequence), sort_key(sort_key) {} On 2016/03/21 19:11:53, gab wrote: ...
4 years, 9 months ago (2016-03-21 19:15:40 UTC) #17
gab
https://codereview.chromium.org/1704113002/diff/80001/base/task_scheduler/priority_queue.cc File base/task_scheduler/priority_queue.cc (right): https://codereview.chromium.org/1704113002/diff/80001/base/task_scheduler/priority_queue.cc#newcode19 base/task_scheduler/priority_queue.cc:19: : sequence(sequence), sort_key(sort_key) {} On 2016/03/21 19:15:40, robliao wrote: ...
4 years, 9 months ago (2016-03-21 19:55:19 UTC) #18
robliao
https://codereview.chromium.org/1704113002/diff/80001/base/task_scheduler/priority_queue.cc File base/task_scheduler/priority_queue.cc (right): https://codereview.chromium.org/1704113002/diff/80001/base/task_scheduler/priority_queue.cc#newcode19 base/task_scheduler/priority_queue.cc:19: : sequence(sequence), sort_key(sort_key) {} On 2016/03/21 19:55:19, gab wrote: ...
4 years, 9 months ago (2016-03-21 19:59:54 UTC) #19
robliao
https://codereview.chromium.org/1704113002/diff/80001/base/task_scheduler/priority_queue.cc File base/task_scheduler/priority_queue.cc (right): https://codereview.chromium.org/1704113002/diff/80001/base/task_scheduler/priority_queue.cc#newcode19 base/task_scheduler/priority_queue.cc:19: : sequence(sequence), sort_key(sort_key) {} On 2016/03/21 19:59:54, robliao wrote: ...
4 years, 9 months ago (2016-03-21 20:06:13 UTC) #20
fdoray
gab@: All done. robliao@: Can you review this CL? gab@ is on vacation now :) ...
4 years, 9 months ago (2016-03-24 19:21:11 UTC) #21
robliao
On the whole, I think I like the new scheme better. Some comments: https://codereview.chromium.org/1704113002/diff/120001/base/task_scheduler/utils.cc File ...
4 years, 9 months ago (2016-03-24 23:03:27 UTC) #22
fdoray
robliao@: I addressed all your comments. Note that the tests sometimes fail because posting a ...
4 years, 8 months ago (2016-03-29 18:33:35 UTC) #25
fdoray
robliao@: Can you review this CL? I plan to use the shared priority queue's lock ...
4 years, 8 months ago (2016-03-29 20:58:32 UTC) #26
robliao
https://codereview.chromium.org/1704113002/diff/120001/base/task_scheduler/worker_thread.cc File base/task_scheduler/worker_thread.cc (right): https://codereview.chromium.org/1704113002/diff/120001/base/task_scheduler/worker_thread.cc#newcode201 base/task_scheduler/worker_thread.cc:201: // hadn't be notified that this WorkerThread was idle ...
4 years, 8 months ago (2016-03-30 00:42:42 UTC) #27
robliao
https://codereview.chromium.org/1704113002/diff/220001/base/task_scheduler/worker_thread.cc File base/task_scheduler/worker_thread.cc (right): https://codereview.chromium.org/1704113002/diff/220001/base/task_scheduler/worker_thread.cc#newcode191 base/task_scheduler/worker_thread.cc:191: state_changed_callback_.Run(this, state); On 2016/03/30 00:42:42, robliao wrote: > I'm ...
4 years, 8 months ago (2016-03-30 00:47:29 UTC) #28
fdoray
robliao@: Can you take another look? I like the idea of using a callback to ...
4 years, 8 months ago (2016-03-30 18:44:49 UTC) #30
robliao
Much simpler! :-) https://codereview.chromium.org/1704113002/diff/220001/base/task_scheduler/worker_thread.cc File base/task_scheduler/worker_thread.cc (right): https://codereview.chromium.org/1704113002/diff/220001/base/task_scheduler/worker_thread.cc#newcode217 base/task_scheduler/worker_thread.cc:217: wake_up_event_.Wait(); On 2016/03/30 18:44:49, fdoray wrote: ...
4 years, 8 months ago (2016-03-30 19:38:27 UTC) #31
fdoray
robliao@: Can you take another look? https://codereview.chromium.org/1704113002/diff/220001/base/task_scheduler/worker_thread.cc File base/task_scheduler/worker_thread.cc (right): https://codereview.chromium.org/1704113002/diff/220001/base/task_scheduler/worker_thread.cc#newcode217 base/task_scheduler/worker_thread.cc:217: wake_up_event_.Wait(); On 2016/03/30 ...
4 years, 8 months ago (2016-03-30 19:56:38 UTC) #32
robliao
lgtm https://codereview.chromium.org/1704113002/diff/260001/base/task_scheduler/worker_thread.h File base/task_scheduler/worker_thread.h (right): https://codereview.chromium.org/1704113002/diff/260001/base/task_scheduler/worker_thread.h#newcode35 base/task_scheduler/worker_thread.h:35: using GetWorkCallback = On 2016/03/30 19:56:37, fdoray wrote: ...
4 years, 8 months ago (2016-03-30 21:35:26 UTC) #33
fdoray
danakj@: Can you review this CL? Thanks.
4 years, 8 months ago (2016-03-30 21:46:20 UTC) #35
danakj
https://codereview.chromium.org/1704113002/diff/280001/base/task_scheduler/worker_thread.cc File base/task_scheduler/worker_thread.cc (right): https://codereview.chromium.org/1704113002/diff/280001/base/task_scheduler/worker_thread.cc#newcode27 base/task_scheduler/worker_thread.cc:27: return scoped_ptr<WorkerThread>(); return nullptr https://codereview.chromium.org/1704113002/diff/280001/base/task_scheduler/worker_thread.h File base/task_scheduler/worker_thread.h (right): https://codereview.chromium.org/1704113002/diff/280001/base/task_scheduler/worker_thread.h#newcode31 ...
4 years, 8 months ago (2016-03-31 00:25:14 UTC) #36
fdoray
danakj@: Thanks for the review. Can you take another look? https://codereview.chromium.org/1704113002/diff/280001/base/task_scheduler/worker_thread.cc File base/task_scheduler/worker_thread.cc (right): https://codereview.chromium.org/1704113002/diff/280001/base/task_scheduler/worker_thread.cc#newcode27 ...
4 years, 8 months ago (2016-03-31 03:26:31 UTC) #37
fdoray
https://codereview.chromium.org/1704113002/diff/280001/base/task_scheduler/worker_thread.h File base/task_scheduler/worker_thread.h (right): https://codereview.chromium.org/1704113002/diff/280001/base/task_scheduler/worker_thread.h#newcode31 base/task_scheduler/worker_thread.h:31: class BASE_EXPORT WorkerThread : public PlatformThread::Delegate { On 2016/03/31 ...
4 years, 8 months ago (2016-03-31 13:29:25 UTC) #38
danakj
LGTM https://codereview.chromium.org/1704113002/diff/280001/base/task_scheduler/worker_thread.h File base/task_scheduler/worker_thread.h (right): https://codereview.chromium.org/1704113002/diff/280001/base/task_scheduler/worker_thread.h#newcode31 base/task_scheduler/worker_thread.h:31: class BASE_EXPORT WorkerThread : public PlatformThread::Delegate { On ...
4 years, 8 months ago (2016-03-31 22:33:49 UTC) #42
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1704113002/320002 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1704113002/320002
4 years, 8 months ago (2016-03-31 22:44:41 UTC) #45
commit-bot: I haz the power
Committed patchset #18 (id:320002)
4 years, 8 months ago (2016-04-01 00:07:57 UTC) #47
commit-bot: I haz the power
Patchset 18 (id:??) landed as https://crrev.com/93649e8fc3faf88cee5a9b03b67199c4bb614b1c Cr-Commit-Position: refs/heads/master@{#384441}
4 years, 8 months ago (2016-04-01 00:09:44 UTC) #49
gab
Did a full scan to catch up on where we are now after my vacation, ...
4 years, 8 months ago (2016-04-05 23:35:20 UTC) #50
fdoray
gab@: I addressed your comments about the unit tests in this CL: https://codereview.chromium.org/1863983006/ I'll create ...
4 years, 8 months ago (2016-04-07 13:56:47 UTC) #51
fdoray
https://codereview.chromium.org/1704113002/diff/320002/base/task_scheduler/scheduler_worker_thread.cc File base/task_scheduler/scheduler_worker_thread.cc (right): https://codereview.chromium.org/1704113002/diff/320002/base/task_scheduler/scheduler_worker_thread.cc#newcode38 base/task_scheduler/scheduler_worker_thread.cc:38: wake_up_event_.Signal(); On 2016/04/05 23:35:20, gab wrote: > Should this ...
4 years, 8 months ago (2016-04-07 16:07:43 UTC) #52
gab
4 years, 8 months ago (2016-04-07 16:49:07 UTC) #53
Message was sent while issue was closed.
Thanks for the follow-up CLs, responding to other discussion below, thanks!

https://codereview.chromium.org/1704113002/diff/320002/base/task_scheduler/sc...
File base/task_scheduler/scheduler_worker_thread.h (right):

https://codereview.chromium.org/1704113002/diff/320002/base/task_scheduler/sc...
base/task_scheduler/scheduler_worker_thread.h:98: mutable SchedulerLock
should_exit_for_testing_lock_;
On 2016/04/07 16:07:43, fdoray wrote:
> On 2016/04/05 23:35:20, gab wrote:
> > Instead of using a lock just for this here we could make
> > |should_exit_for_testing_| volatile, also makes the impl cleaner IMO since
it
> > doesn't have to have locking scopes :-).
> > 
> > Note: if I understand the C++ standard correctly I think this means you'll
> have
> > to make the methods using |should_exit_for_testing_| volatile as well (same
> > semantics as "const"). Never used volatile in C++ but curious whether it'd
> make
> > things cleaner here :-)?
> 
> If should_exit_for_testing_ is volatile:
> 
> Thread 1:
>   should_exit_for_testing_ = true;
>   wake_up_event_.Signal();
> 
> Thread 2:
>   wake_up_event_.Wait();
>   if (should_exit_for_testing_) {}
> 
> There is no guarantee that the condition is true on thread 2 unless we know
that
> WaitableEvent::Signal/Wait both have visible side effects. I'm pretty sure
that
> these methods have visible side effects (pending input from etienneb@), but I
> don't like relying on that fact.
> 
> "within a single thread of execution, volatile accesses cannot be optimized
out
> or reordered with another visible side effect that is sequenced-before or
> sequenced-after the volatile access. This makes volatile objects suitable for
> communication with a signal handler, but not with another thread of execution,
> see std::memory_order" http://en.cppreference.com/w/cpp/language/cv
>   

Ah interesting, so it's not like Java's volatile which, IIRC, is essentially
like wrapping all access to |foo| into a |synchronized(foo){}| block. I guess
that's because Java natively supports multi-threading whereas C++ doesn't.

Powered by Google App Engine
This is Rietveld 408576698