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

Issue 387493002: Fixing and enhancing OrderedSimpleTaskRunner to allow 100% deterministic tests. (Closed)

Created:
6 years, 5 months ago by mithro-old
Modified:
6 years, 3 months ago
Reviewers:
brianderson, Sami
CC:
cc-bugs_chromium.org, chromium-reviews, simonhong
Project:
chromium
Visibility:
Public.

Description

New features include; * Actually running the tasks in the ordered you asked! * Allow running only pending tasks, all tasks until idle, to a given time or for a given period. * Allow stopping of running tasks on *any* arbitrary condition. No longer will your tasks stop working when someone adds a new task or changes the task order! * Task runner intimately connected to time and controls Now(). Supports both automatic management and manual control. This change makes it possible for the scheduler_unit tests to be 100% deterministic. It also allows them to be more flexible and less brittle. BUG=380889 Committed: https://crrev.com/0c0ac6a1616778e3852e3f8b3248688ca9d899b2 Cr-Commit-Position: refs/heads/master@{#294059}

Patch Set 1 #

Patch Set 2 : Using iterator. #

Patch Set 3 : Adding unittests into ordered_simple_task_runner and fixing compile error. #

Patch Set 4 : sprintf is hard. #

Total comments: 12

Patch Set 5 : Rebase onto master. #

Patch Set 6 : Fixing code review issues. #

Patch Set 7 : Lots of changes. #

Total comments: 8

Patch Set 8 : Rebase onto master after 3 weeks. #

Patch Set 9 : Lint fixes. #

Patch Set 10 : Small fixes. #

Patch Set 11 : Tests now pass. #

Patch Set 12 : Using SizeTToString rather then c++11 to_string. #

Total comments: 42

Patch Set 13 : Refactoring the code so that the Now source is a seperate concept from the OrderedSimpleTaskRunner. #

Patch Set 14 : Fixing the gn build. #

Total comments: 3

Patch Set 15 : Refactoring the code to allow arbitary conditions for stopping to process tasks. Reimplimented all … #

Patch Set 16 : Rebase onto master. #

Total comments: 29

Patch Set 17 : Rebase onto master. #

Patch Set 18 : Refactoring to use base::Closure rather then micro-classes. #

Patch Set 19 : Trying to fix gcc. #

Patch Set 20 : Fixing Windows compile (no idea why this worked on non-windows!) #

Total comments: 26

Patch Set 21 : Fixing android compile issue. #

Patch Set 22 : Fixing for Sami's review. #

Total comments: 14

Patch Set 23 : Fixing for Brian's review. #

Total comments: 2

Patch Set 24 : Fixes for Brian's comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1295 lines, -175 lines) Patch
M cc/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +2 lines, -0 lines 0 comments Download
M cc/cc_tests.gyp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +2 lines, -0 lines 0 comments Download
M cc/scheduler/scheduler.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 4 chunks +5 lines, -3 lines 0 comments Download
M cc/scheduler/scheduler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 9 chunks +27 lines, -17 lines 0 comments Download
M cc/scheduler/scheduler_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 59 chunks +101 lines, -114 lines 0 comments Download
M cc/test/begin_frame_args_test.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +8 lines, -0 lines 0 comments Download
M cc/test/begin_frame_args_test.cc View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +16 lines, -0 lines 0 comments Download
M cc/test/ordered_simple_task_runner.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 chunk +124 lines, -2 lines 0 comments Download
M cc/test/ordered_simple_task_runner.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 chunk +303 lines, -19 lines 0 comments Download
M cc/test/ordered_simple_task_runner_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +400 lines, -20 lines 0 comments Download
M cc/test/scheduler_test_common.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +74 lines, -0 lines 0 comments Download
M cc/test/scheduler_test_common.cc View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +48 lines, -0 lines 0 comments Download
A cc/test/test_now_source.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +60 lines, -0 lines 0 comments Download
A cc/test/test_now_source.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +125 lines, -0 lines 0 comments Download

Messages

Total messages: 40 (1 generated)
mithro-old
Hi Sami / Brian, This CL doesn't quite work yet, it triggers a bunch of ...
6 years, 5 months ago (2014-07-10 12:31:36 UTC) #1
Sami
I like the idea. Quick thought: would it scale better to make it possible for ...
6 years, 5 months ago (2014-07-10 14:02:11 UTC) #2
mithro-old
On 2014/07/10 14:02:11, Sami wrote: > I like the idea. Quick thought: would it scale ...
6 years, 5 months ago (2014-07-11 00:39:50 UTC) #3
mithro-old
On 2014/07/11 00:39:50, mithro wrote: > On 2014/07/10 14:02:11, Sami wrote: > > I like ...
6 years, 5 months ago (2014-07-11 10:43:24 UTC) #4
Sami
https://codereview.chromium.org/387493002/diff/60001/cc/test/ordered_simple_task_runner.h File cc/test/ordered_simple_task_runner.h (right): https://codereview.chromium.org/387493002/diff/60001/cc/test/ordered_simple_task_runner.h#newcode24 cc/test/ordered_simple_task_runner.h:24: void SetAdvanceNow(bool advance_now) { advance_now_ = advance_now; } Looks ...
6 years, 5 months ago (2014-07-11 17:22:46 UTC) #5
brianderson
Like where this is headed. Hopefully I can use this to fix some of the ...
6 years, 5 months ago (2014-07-14 23:42:32 UTC) #6
mithro-old
On 2014/07/14 23:42:32, brianderson wrote: > Like where this is headed. Hopefully I can use ...
6 years, 5 months ago (2014-07-14 23:50:03 UTC) #7
mithro-old
Hi Brian / Sami, This patch has changed quite a bit since you last looked ...
6 years, 5 months ago (2014-07-16 14:18:12 UTC) #8
brianderson
https://codereview.chromium.org/387493002/diff/140001/cc/scheduler/scheduler_state_machine.cc File cc/scheduler/scheduler_state_machine.cc (right): https://codereview.chromium.org/387493002/diff/140001/cc/scheduler/scheduler_state_machine.cc#newcode166 cc/scheduler/scheduler_state_machine.cc:166: base::TimeTicks now = base::TimeTicks(); // gfx::FrameTime::Now(); Why did this ...
6 years, 5 months ago (2014-07-17 05:26:03 UTC) #9
mithro-old
Hi Brian, Haven't had a chance to upload a new version but wanted to reply ...
6 years, 5 months ago (2014-07-17 06:51:58 UTC) #10
mithro-old
Hi Brian / Sami, Can you please take another look at this change? I'm still ...
6 years, 4 months ago (2014-08-18 06:11:06 UTC) #11
mithro-old
Hi guys, The tests now all pass as far as I can see. Can you ...
6 years, 4 months ago (2014-08-19 06:32:47 UTC) #12
Sami
Thanks Tim, I think this looks pretty good. Added some miscellaneous thoughts. https://codereview.chromium.org/387493002/diff/240001/cc/scheduler/scheduler.h File cc/scheduler/scheduler.h ...
6 years, 4 months ago (2014-08-19 18:45:04 UTC) #13
brianderson
One major comment about the structure: it's confusing that OrderedSimpleTaskRunner is the owner of time ...
6 years, 4 months ago (2014-08-20 20:04:31 UTC) #14
mithro-old
Hi Brian, I've refactored the Now time source out into it's own TestNowSource class. OrderedSimpleTaskRunner ...
6 years, 4 months ago (2014-08-21 17:39:19 UTC) #15
brianderson
https://codereview.chromium.org/387493002/diff/240001/cc/scheduler/scheduler_unittest.cc File cc/scheduler/scheduler_unittest.cc (left): https://codereview.chromium.org/387493002/diff/240001/cc/scheduler/scheduler_unittest.cc#oldcode268 cc/scheduler/scheduler_unittest.cc:268: EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); In your description of the possible states at ...
6 years, 4 months ago (2014-08-21 21:48:52 UTC) #16
mithro-old
Hi Brian, FYI Here is a screenshot of the different runs, dunno if it'll make ...
6 years, 4 months ago (2014-08-22 04:16:26 UTC) #17
brianderson
https://codereview.chromium.org/387493002/diff/240001/cc/scheduler/scheduler_unittest.cc File cc/scheduler/scheduler_unittest.cc (right): https://codereview.chromium.org/387493002/diff/240001/cc/scheduler/scheduler_unittest.cc#newcode232 cc/scheduler/scheduler_unittest.cc:232: client->task_runner().RunPendingTasks(); Thanks for attaching the diff, it made it ...
6 years, 4 months ago (2014-08-22 23:34:26 UTC) #18
brianderson
6 years, 4 months ago (2014-08-22 23:34:29 UTC) #19
mithro-old
Hi Brian / Sami (and Simon), After looking into your idea of adding a OrderedSimpleTaskRunner::RunNextPendingTask() ...
6 years, 3 months ago (2014-08-27 16:25:01 UTC) #20
Sami
I sort of like the idea of a run-until-condition-x message loop, but I worry that ...
6 years, 3 months ago (2014-08-27 19:18:11 UTC) #21
brianderson
Sami brings up a good point. Using a condition to stop running tasks might make ...
6 years, 3 months ago (2014-08-28 03:12:37 UTC) #22
mithro-old
On 28 August 2014 13:12, <brianderson@chromium.org> wrote: > Sami brings up a good point. Using ...
6 years, 3 months ago (2014-08-28 05:10:56 UTC) #23
brianderson
https://codereview.chromium.org/387493002/diff/320001/cc/test/ordered_simple_task_runner.h File cc/test/ordered_simple_task_runner.h (right): https://codereview.chromium.org/387493002/diff/320001/cc/test/ordered_simple_task_runner.h#newcode75 cc/test/ordered_simple_task_runner.h:75: base::Callback<bool(void)> AsCallback() const; Why is this needed? https://codereview.chromium.org/387493002/diff/320001/cc/test/ordered_simple_task_runner.h#newcode140 cc/test/ordered_simple_task_runner.h:140: ...
6 years, 3 months ago (2014-08-28 22:15:17 UTC) #24
Sami
https://codereview.chromium.org/387493002/diff/320001/cc/scheduler/scheduler.h File cc/scheduler/scheduler.h (right): https://codereview.chromium.org/387493002/diff/320001/cc/scheduler/scheduler.h#newcode157 cc/scheduler/scheduler.h:157: scoped_refptr<DelayBasedTimeSource> time_source); Could this be a scoped_ptr instead? Looks ...
6 years, 3 months ago (2014-08-29 13:13:52 UTC) #25
mithro-old
Hi Sami / Brian, Took on your feedback regarding the micro classes and refactored to ...
6 years, 3 months ago (2014-09-01 06:19:46 UTC) #26
Sami
Thanks for simplifying. https://codereview.chromium.org/387493002/diff/320001/cc/scheduler/scheduler_unittest.cc File cc/scheduler/scheduler_unittest.cc (right): https://codereview.chromium.org/387493002/diff/320001/cc/scheduler/scheduler_unittest.cc#newcode246 cc/scheduler/scheduler_unittest.cc:246: scoped_refptr<TestNowSource> now_src_; On 2014/09/01 06:19:46, mithro ...
6 years, 3 months ago (2014-09-01 11:35:33 UTC) #27
mithro-old
Fixed Sami's comments. Can you see anything else major Sami? (Obviously will wait on Brian's ...
6 years, 3 months ago (2014-09-01 12:00:19 UTC) #28
Sami
https://codereview.chromium.org/387493002/diff/400001/cc/test/ordered_simple_task_runner.cc File cc/test/ordered_simple_task_runner.cc (right): https://codereview.chromium.org/387493002/diff/400001/cc/test/ordered_simple_task_runner.cc#newcode130 cc/test/ordered_simple_task_runner.cc:130: if (pending_tasks_.size() <= 0) On 2014/09/01 12:00:19, mithro wrote: ...
6 years, 3 months ago (2014-09-01 12:50:29 UTC) #29
brianderson
https://codereview.chromium.org/387493002/diff/440001/cc/test/ordered_simple_task_runner.cc File cc/test/ordered_simple_task_runner.cc (right): https://codereview.chromium.org/387493002/diff/440001/cc/test/ordered_simple_task_runner.cc#newcode180 cc/test/ordered_simple_task_runner.cc:180: if (inside_run_tasks_until_) Should this early out and the AutoReset ...
6 years, 3 months ago (2014-09-05 02:48:03 UTC) #30
mithro-old
Will try and get to these ASAP. Is there anything else that needs to be ...
6 years, 3 months ago (2014-09-05 08:07:11 UTC) #31
Sami
I had another look and I think looks good to go after the changes Brian ...
6 years, 3 months ago (2014-09-05 12:55:13 UTC) #32
mithro-old
PTAL Tim https://codereview.chromium.org/387493002/diff/440001/cc/test/ordered_simple_task_runner.cc File cc/test/ordered_simple_task_runner.cc (right): https://codereview.chromium.org/387493002/diff/440001/cc/test/ordered_simple_task_runner.cc#newcode180 cc/test/ordered_simple_task_runner.cc:180: if (inside_run_tasks_until_) On 2014/09/05 02:48:03, brianderson wrote: ...
6 years, 3 months ago (2014-09-08 12:52:20 UTC) #33
brianderson
Should be the last round of comments from me. https://codereview.chromium.org/387493002/diff/440001/cc/test/ordered_simple_task_runner.cc File cc/test/ordered_simple_task_runner.cc (right): https://codereview.chromium.org/387493002/diff/440001/cc/test/ordered_simple_task_runner.cc#newcode192 cc/test/ordered_simple_task_runner.cc:192: ...
6 years, 3 months ago (2014-09-08 19:24:08 UTC) #34
mithro-old
https://codereview.chromium.org/387493002/diff/440001/cc/test/ordered_simple_task_runner.cc File cc/test/ordered_simple_task_runner.cc (right): https://codereview.chromium.org/387493002/diff/440001/cc/test/ordered_simple_task_runner.cc#newcode192 cc/test/ordered_simple_task_runner.cc:192: return pending_tasks_.size() > 0; On 2014/09/08 19:24:08, brianderson wrote: ...
6 years, 3 months ago (2014-09-09 02:39:45 UTC) #35
brianderson
lgtm
6 years, 3 months ago (2014-09-09 18:12:20 UTC) #36
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mithro@mithis.com/387493002/480001
6 years, 3 months ago (2014-09-09 23:52:01 UTC) #38
commit-bot: I haz the power
Committed patchset #24 (id:480001) as 2fa82c49e96927ff704f7c980d068a54418a508d
6 years, 3 months ago (2014-09-10 01:08:23 UTC) #39
commit-bot: I haz the power
6 years, 3 months ago (2014-09-10 03:57:13 UTC) #40
Message was sent while issue was closed.
Patchset 24 (id:??) landed as
https://crrev.com/0c0ac6a1616778e3852e3f8b3248688ca9d899b2
Cr-Commit-Position: refs/heads/master@{#294059}

Powered by Google App Engine
This is Rietveld 408576698