-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Prefer std::atomic over MemoryBarrier #449
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
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
tACK Compiled and confirmed there were no errors. All tests passed, and the benchmarks (static and shared) seemed reasonable at a glance. Didn't benchmark vis-à-vis my fix (#422). sipa's fix, after thinking about it, seems preferable to mine, although I'll leave mine open in case the team thinks otherwise. |
Thank you very much for your contribution! The comment at the top of While I'm not sure this toolchain issue is relevant anymore, we'd need to do some testing to confirm. Do you happen to have access to the platforms that have MemoryBarrier implementations? If it turns out that std::atomic implementations in modern toolchains are good enough, we can remove the MemoryBarrier code altogether, because we'll require C++11 soon. |
@googlebot rescan |
1 similar comment
@googlebot rescan |
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
We removed AtomicPointer a while back. The codebase uses |
In port/atomic_pointer.h, the preference is to use MemoryBarrier if available, and only fall back to std::atomic if it isn't available.
I believe it would be preferable to use std::atomic, as it may allow better performance, and integrates without changes into ThreadSanitizer.
This PR changes the preference to std::atomic if available.