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

Issue 614723003: Avoid scheduling a message loop that we know is not sleeping (Closed)

Created:
6 years, 2 months ago by jamesr
Modified:
6 years ago
CC:
chromium-reviews, erikwright+watch_chromium.org, sadrul
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

Avoid scheduling a message loop that we know is not sleeping When tasks are posted to a message loop, we may need to schedule the message loop to wake up if it was sleeping so it processes the message. The incoming task queue checks whether the incoming queue was already empty as a way to avoid scheduling unnecessarily, but we can be more precise. Once a message loop is scheduled, we know that it will sooner or later wake up and enter its run loop. In its run loop it will repeatedly drain the work queue and attempt to reload from the incoming queue until there is no work immediately available to do. This means that before waiting for more work the loop will always reload from an empty incoming queue. Thus, once we schedule a loop we do not need to schedule the same loop again until after an empty reload occurs. This adds a bool to IncomingTaskQueue protected by the incoming task queue lock that keeps track of if the loop has been scheduled since the last empty reload. Local testing on Linux desktop and a ChromeShell Android build shows that this avoids roughly 40% of the ScheduleWork calls when browsing around to random websites. This also has the very nice consequence that when running a task and posting another task to the same thread we *never* need to invoke ScheduleWork which avoids the cost of the ScheduleWork call and avoids a spurious wakeup when going to sleep. BUG=412137 Committed: https://crrev.com/23a5e54a3ae47b3f5dfb9ca62e19f10db02d1b42 Cr-Commit-Position: refs/heads/master@{#308221}

Patch Set 1 #

Total comments: 4

Patch Set 2 : address comments from rvargas #

Patch Set 3 : fix message_loop.h header merge issue #

Patch Set 4 : fix base_perftests compilation #

Patch Set 5 : fix android java pump scheduling #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+50 lines, -22 lines) Patch
M base/message_loop/incoming_task_queue.h View 1 chunk +8 lines, -0 lines 0 comments Download
M base/message_loop/incoming_task_queue.cc View 1 2 3 4 3 chunks +38 lines, -5 lines 1 comment Download
M base/message_loop/message_loop.h View 1 2 1 chunk +1 line, -1 line 0 comments Download
M base/message_loop/message_loop.cc View 1 2 chunks +2 lines, -15 lines 0 comments Download
M base/message_loop/message_pump_perftest.cc View 1 2 3 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 28 (10 generated)
jamesr
Dana and/or Ricardo - would you mind taking a look at this patch? It should ...
6 years, 1 month ago (2014-11-15 01:52:42 UTC) #2
rvargas (doing something else)
Cool!. lgtm after nits. https://codereview.chromium.org/614723003/diff/1/base/message_loop/incoming_task_queue.cc File base/message_loop/incoming_task_queue.cc (right): https://codereview.chromium.org/614723003/diff/1/base/message_loop/incoming_task_queue.cc#newcode17 base/message_loop/incoming_task_queue.cc:17: // Returns true if MessagePump::ScheduleWork() ...
6 years, 1 month ago (2014-11-17 19:18:50 UTC) #3
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/614723003/20001
6 years ago (2014-12-08 22:52:10 UTC) #5
commit-bot: I haz the power
Try jobs failed on following builders: android_chromium_gn_compile_dbg on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/android_chromium_gn_compile_dbg/builds/23986)
6 years ago (2014-12-08 22:59:19 UTC) #7
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/614723003/40001
6 years ago (2014-12-08 23:05:17 UTC) #9
commit-bot: I haz the power
Try jobs failed on following builders: android_dbg_tests_recipe on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/android_dbg_tests_recipe/builds/35521)
6 years ago (2014-12-08 23:20:22 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/614723003/60001
6 years ago (2014-12-09 01:34:33 UTC) #13
commit-bot: I haz the power
Try jobs failed on following builders: android_dbg_tests_recipe on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/android_dbg_tests_recipe/builds/35614)
6 years ago (2014-12-09 05:37:53 UTC) #15
jamesr
Seems to be having trouble on some android tests, which isn't super surprising since the ...
6 years ago (2014-12-10 21:58:46 UTC) #16
jamesr
I was able to repro the android instrumentation test failures locally and construct a fix ...
6 years ago (2014-12-11 02:26:39 UTC) #17
rvargas (doing something else)
6 years ago (2014-12-11 18:28:22 UTC) #18
rvargas (doing something else)
lgtm
6 years ago (2014-12-11 18:28:32 UTC) #19
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/614723003/80001
6 years ago (2014-12-11 18:29:13 UTC) #21
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_asan_rel on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_asan_rel/builds/17288)
6 years ago (2014-12-11 21:10:13 UTC) #23
jamesr
On 2014/12/11 21:10:13, I haz the power (commit-bot) wrote: > Try jobs failed on following ...
6 years ago (2014-12-13 01:53:05 UTC) #25
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/614723003/80001
6 years ago (2014-12-13 01:53:55 UTC) #26
commit-bot: I haz the power
Committed patchset #5 (id:80001)
6 years ago (2014-12-13 01:55:38 UTC) #27
commit-bot: I haz the power
6 years ago (2014-12-13 01:56:34 UTC) #28
Message was sent while issue was closed.
Patchset 5 (id:??) landed as
https://crrev.com/23a5e54a3ae47b3f5dfb9ca62e19f10db02d1b42
Cr-Commit-Position: refs/heads/master@{#308221}

Powered by Google App Engine
This is Rietveld 408576698