Closed AngelicosPhosphoros closed 6 months ago
This generates different code than current for aarch64-apple-darwin
, allowing it to do more instruction reordering for unrelated memory accesses.
It seems the ordering was changed from Acquire
to SeqCst
in commit 28ce2f8b963e602da385c4c9698306ad1b1c8ae9, specifically: https://github.com/rust-lang/log/commit/28ce2f8b963e602da385c4c9698306ad1b1c8ae9#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759R552, from pr #12.
@sfackler you wrote the code, but the commit message doesn't mention why. Do you know of a good reason not to merge this?
@Thomasdezeeuw It seems that @sfackler wouldn't respond.
Anyway, this old code was very different (e.g. it uses refcounting, and with too strong orderings too, Arc, for example, uses mostly acquire and relaxed orderings).
I wrote the comment in code that explains why Acquire ordering is correct and enough. With atomics, in general, it is preferable to use weakest as possible but still correct ordering because stronger ordering does make whole CPU slower, especially, if called frequently.
If I remember correctly, it was Alex’s general preference to use stronger orderings to avoid potential correctness issues. I wouldn’t read to much into it if people are confident that a weaker ordering is sufficient.
Thanks @sfackler
Then I think we can merge this.
Thanks @AngelicosPhosphoros
Reasoning is provided in a comment.