DISPATCH-1344 Relaxing C11 sys_atomic_ operations #239
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a revival of DISPATCH-1344. The issue that was never meant to have been abandoned.
@astitcher The shared_ptr article about atomics is actually not an article, but a SO question, https://stackoverflow.com/questions/28199212/why-does-libcs-implementation-of-shared-ptr-use-full-memory-barriers-instead
Regarding the question "What use are the relaxed atomics on x86_64?", as far as I can tell, the hardware recognizes two "levels":
seq_cst
andeverything else
. By that I mean that the generated code for seq_cst store is actually different from non-cst_seq store. But, the relaxation also influences what code will be generated by the compiler. Even if the CPU does not do reorders, the compiler will, and that may be significant for performance, sometimes. (https://stackoverflow.com/questions/61719680/are-memory-orderings-consume-acq-rel-and-seq-cst-ever-needed-on-intel-x86)So, IMO if this shows promise in benchmark, then there may be value in thinking about this. Ultimately, the atomics, as a way to silence TSan, were not all that great a solution and hopefully they will go away, eventually.