Skip to content
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

Are these stronger guarantees actually needed? #2

Open
thirtythreeforty opened this issue Sep 8, 2017 · 1 comment
Open

Are these stronger guarantees actually needed? #2

thirtythreeforty opened this issue Sep 8, 2017 · 1 comment

Comments

@thirtythreeforty
Copy link

This library is awesome, thanks!

Quick performance question. This code:

#define memory_order_release memory_order_seq_cst
#define memory_order_acquire memory_order_seq_cst
#define memory_order_relaxed memory_order_seq_cst

makes sure that all atomic operations happen with the maximum amount of synchronization. Is this required, or is this code just erring on the side of caution?

@thirtythreeforty thirtythreeforty changed the title Stronger guarantees needed? Are these stronger guarantees actually needed? Sep 8, 2017
@dbittman
Copy link
Owner

dbittman commented Sep 8, 2017

It's erring on the side of caution. I have not fully verified the correctness of the relaxed ordering (though I believe it's right, according to a reading of the standard that I did when I wrote it). I have found that on x86 it makes little difference, and on armv8 there is a very small (but statistically significant) performance increase when using the relaxed orderings. Additionally, there are lines in the relaxed orderings that could possibly be relaxed further, if of course the code is correct with the current relaxed orderings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants