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

Issue 1154953002: Set minimum Windows wait time to 1 ms in MessagePumpDefault::Run (Closed)

Created:
5 years, 7 months ago by brucedawson
Modified:
5 years, 7 months ago
CC:
chromium-reviews, erikwright+watch_chromium.org, sadrul, ananta
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Set minimum Windows wait time to 1 ms in MessagePumpDefault::Run On Windows if we call event_.TimedWait(delay); with a sub-ms delay then the wait function will return immediately. This means we end up busy waiting down to zero. Rounding these times up to 1 ms lets Chrome go idle and saves a few percent of a core on some tests. The symptom to watch for is lots of time being spent in QPCNow, called from MessagePumpDefault::Run or from MessageLoop::DoDelayedWork. This is the second attempt at fixing this bug. The first attempt tried rounding down the short delays but this was stymied by other code that didn't respect the rounding down. One known problem is that some animations that try to run at 60 fps by using setInterval(C,16) will drop from ~60 fps to ~58 fps. Those that use requestAnimationFrame run at a steady rate of 60 fps. BUG=487724 Committed: https://crrev.com/932c2457349e44eeb7b3152f8b49acd186e7057e Cr-Commit-Position: refs/heads/master@{#331226}

Patch Set 1 #

Total comments: 1

Patch Set 2 : Simpler implementation using std::max #

Patch Set 3 : Check for > zero first. #

Total comments: 1

Patch Set 4 : Remove unnecessary braces. #

Patch Set 5 : Add missing header include. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+10 lines, -2 lines) Patch
M base/message_loop/message_pump_default.cc View 1 2 3 4 2 chunks +10 lines, -2 lines 0 comments Download

Messages

Total messages: 17 (6 generated)
brucedawson
Possible alternative fix. A ~2-6% reduction in CPU time consumed across all Chrome processes was ...
5 years, 7 months ago (2015-05-22 18:10:06 UTC) #2
cpu_(ooo_6.6-7.5)
https://codereview.chromium.org/1154953002/diff/1/base/message_loop/message_pump_default.cc File base/message_loop/message_pump_default.cc (right): https://codereview.chromium.org/1154953002/diff/1/base/message_loop/message_pump_default.cc#newcode55 base/message_loop/message_pump_default.cc:55: #if defined(OS_WIN) delay = std::max(delay, TimeDelta::FromMilliseconds(1)) now if we ...
5 years, 7 months ago (2015-05-22 21:36:42 UTC) #3
brucedawson
If we can get rounding down to work then rounding down at 500us would be ...
5 years, 7 months ago (2015-05-22 22:08:47 UTC) #4
cpu_(ooo_6.6-7.5)
https://codereview.chromium.org/1154953002/diff/40001/base/message_loop/message_pump_default.cc File base/message_loop/message_pump_default.cc (right): https://codereview.chromium.org/1154953002/diff/40001/base/message_loop/message_pump_default.cc#newcode59 base/message_loop/message_pump_default.cc:59: if (delay > TimeDelta()) { don't use the braces ...
5 years, 7 months ago (2015-05-22 22:57:54 UTC) #5
brucedawson
Fixed.
5 years, 7 months ago (2015-05-22 23:00:32 UTC) #6
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1154953002/60001
5 years, 7 months ago (2015-05-22 23:02:26 UTC) #9
commit-bot: I haz the power
Try jobs failed on following builders: win8_chromium_rel on tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win8_chromium_rel/builds/86712)
5 years, 7 months ago (2015-05-23 00:14:17 UTC) #11
brucedawson
It's not clear why std::max was available in some configurations but not others. Including <algorithm> ...
5 years, 7 months ago (2015-05-23 00:34:13 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1154953002/80001
5 years, 7 months ago (2015-05-23 00:40:02 UTC) #15
commit-bot: I haz the power
Committed patchset #5 (id:80001)
5 years, 7 months ago (2015-05-23 03:12:11 UTC) #16
commit-bot: I haz the power
5 years, 7 months ago (2015-05-23 03:13:01 UTC) #17
Message was sent while issue was closed.
Patchset 5 (id:??) landed as
https://crrev.com/932c2457349e44eeb7b3152f8b49acd186e7057e
Cr-Commit-Position: refs/heads/master@{#331226}

Powered by Google App Engine
This is Rietveld 408576698