-
Notifications
You must be signed in to change notification settings - Fork 15.6k
[libc++] Use native wait in std::barrier instead of sleep loop #171041
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
6ce071d to
cd942d4
Compare
cd942d4 to
19eaea4
Compare
|
@llvm/pr-subscribers-libcxx Author: Hui (huixie90) Changesnot sure why but the current Full diff: https://github.com/llvm/llvm-project/pull/171041.diff 1 Files Affected:
diff --git a/libcxx/include/barrier b/libcxx/include/barrier
index 5f9b471f01741..10d40f32919c8 100644
--- a/libcxx/include/barrier
+++ b/libcxx/include/barrier
@@ -142,8 +142,7 @@ public:
return __old_phase;
}
_LIBCPP_HIDE_FROM_ABI void wait(arrival_token&& __old_phase) const {
- auto const __test_fn = [this, __old_phase]() -> bool { return __phase_.load(memory_order_acquire) != __old_phase; };
- std::__libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy());
+ __phase_.wait(__old_phase, std::memory_order_acquire);
}
_LIBCPP_HIDE_FROM_ABI void arrive_and_drop() {
__expected_adjustment_.fetch_sub(1, memory_order_relaxed);
|
ldionne
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! This seems like an obvious improvement.
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/169/builds/18010 Here is the relevant piece of the build log for the reference |
…171041) For some reason, the current `std::barrier`'s wait implementation polls the underlying atomic in a loop with sleeps instead of using the native wait. This change should also indirectly fix the performance issue of `std::barrier` described in llvm#123855. Fixes llvm#123855
…171041) For some reason, the current `std::barrier`'s wait implementation polls the underlying atomic in a loop with sleeps instead of using the native wait. This change should also indirectly fix the performance issue of `std::barrier` described in llvm#123855. Fixes llvm#123855
For some reason, the current
std::barrier's wait implementation polls the underlying atomic in a loop with sleeps instead of using the native wait.Before this change, on the CI runner , lost_wakeup.pass.cpp was the slowest test , which uses
std::barrier===
macOS CXX23
Before:
After
===
Linux CXX23:
Before
After:
No longer in the slowest tests list
===
Windows:
Before
After
No longer in the slowest test list
This change should also indirectly fix the performance issue of
std::barrierdescribed in #123855.Fixes #123855