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

Issue 2758853002: Ensure consistent return ordering in base::WaitableEvent::WaitMany (Closed)

Created:
3 years, 9 months ago by Ken Rockot(use gerrit already)
Modified:
3 years, 9 months ago
Reviewers:
dcheng
CC:
chromium-reviews, vmpstr+watch_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Ensure consistent return ordering in base::WaitableEvent::WaitMany The Windows implementation (via WaitForMultipleObjects) guarantees that if multiple objects are signaled, the one with the smallest index is returned on wakeup. This is a useful guarantee to make, as callers are granted the ability to rotate objects as needed to avoid potential starvation of lower-frequency events. The POSIX implementation of WaitMany does not support this behavior, as precedence is determined exclusively by WaitableEvent address order rather than input array order. The behavior today is a result of the implementation detail that we must lock the WaitableEvent kernels in a globally consistent order, and this makes it effectively impossible for a caller to control signaling priority. This CL changes the POSIX implementation to guarantee the same return behavior as the Windows implementation, allowing the WaitMany API to in turn guarantee left-to-right precedence of the WaitableEvents with which it's called. This has some minor additional cost as we no longer short-circuit on the first signaled event we find, and we always have to iterate over the array twice now. This cost is negligible in practice as WaitMany is only ever used in production with a small (n < 5) number of events. BUG=698460 Review-Url: https://codereview.chromium.org/2758853002 Cr-Commit-Position: refs/heads/master@{#457967} Committed: https://chromium.googlesource.com/chromium/src/+/926b72bf8aba665d906fe411a11a9f587335c1bb

Patch Set 1 #

Patch Set 2 : . #

Patch Set 3 : rebase #

Total comments: 2

Patch Set 4 : nit+rebase #

Patch Set 5 : rebase #

Unified diffs Side-by-side diffs Delta from patch set Stats (+78 lines, -26 lines) Patch
M base/synchronization/waitable_event.h View 1 chunk +3 lines, -0 lines 0 comments Download
M base/synchronization/waitable_event_posix.cc View 1 2 3 3 chunks +37 lines, -26 lines 0 comments Download
M base/synchronization/waitable_event_unittest.cc View 1 2 chunks +38 lines, -0 lines 0 comments Download

Messages

Total messages: 30 (22 generated)
Ken Rockot(use gerrit already)
PTAL, thanks!
3 years, 9 months ago (2017-03-17 17:22:01 UTC) #5
dcheng
LGTM https://codereview.chromium.org/2758853002/diff/40001/base/synchronization/waitable_event_posix.cc File base/synchronization/waitable_event_posix.cc (right): https://codereview.chromium.org/2758853002/diff/40001/base/synchronization/waitable_event_posix.cc#newcode357 base/synchronization/waitable_event_posix.cc:357: for (int i = static_cast<int>(count - 1); i ...
3 years, 9 months ago (2017-03-17 22:53:47 UTC) #14
Ken Rockot(use gerrit already)
Thanks! https://codereview.chromium.org/2758853002/diff/40001/base/synchronization/waitable_event_posix.cc File base/synchronization/waitable_event_posix.cc (right): https://codereview.chromium.org/2758853002/diff/40001/base/synchronization/waitable_event_posix.cc#newcode357 base/synchronization/waitable_event_posix.cc:357: for (int i = static_cast<int>(count - 1); i ...
3 years, 9 months ago (2017-03-18 00:05:25 UTC) #17
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2758853002/80001
3 years, 9 months ago (2017-03-18 00:07:16 UTC) #22
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_chromeos_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_chromeos_rel_ng/builds/386424)
3 years, 9 months ago (2017-03-18 02:32:52 UTC) #24
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2758853002/80001
3 years, 9 months ago (2017-03-18 09:53:34 UTC) #26
commit-bot: I haz the power
Committed patchset #5 (id:80001) as https://chromium.googlesource.com/chromium/src/+/926b72bf8aba665d906fe411a11a9f587335c1bb
3 years, 9 months ago (2017-03-18 11:23:04 UTC) #29
BigBossZhiling
3 years, 9 months ago (2017-03-21 22:06:22 UTC) #30
Message was sent while issue was closed.
A revert of this CL (patchset #5 id:80001) has been created in
https://codereview.chromium.org/2761993004/ by hzl@google.com.

The reason for reverting is: Causing extra time for chrome_public_test_apk,
telemetry_perf_unittests etc..

Powered by Google App Engine
This is Rietveld 408576698