-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Improve comments from #72617, as suggested by RalfJung #73925
Conversation
src/libstd/panicking.rs
Outdated
@@ -263,6 +263,11 @@ pub mod panic_count { | |||
// Fast path: if `GLOBAL_PANIC_COUNT` is zero, all threads | |||
// (including the current one) will have `LOCAL_PANIC_COUNT` | |||
// equal to zero, so TLS access can be avoided. | |||
// | |||
// A relaxed atomic load is equivalent to a normal aligned memory read | |||
// (e.g., a `mov` instruction in x86), while a TLS access might require |
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.
It is not equivalent. The compiler can optimize relaxed less than it can optimize normal reads.
Another way to see that they are not equivalent: replacing this relaxed access by a normal aligned read would result in Undefined Behavior. If two things are truly equivalent, then replacing one by the other changes nothing.
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.
What about "In terms of performance, a relaxed atomic load is similar to a normal aligned memory read (e.g., a mov
instruction in x86), but with some compiler optimization restrictions."?
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.
That sounds great. :)
Thanks. :) |
📌 Commit 0f1adc8 has been approved by |
⌛ Testing commit 0f1adc8 with merge c37547168f1b0b298cbb96aedbbf9fc1b46dc209... |
💔 Test failed - checks-actions |
@bors retry |
…arth Rollup of 12 pull requests Successful merges: - rust-lang#73140 (Fallback to xml.etree.ElementTree) - rust-lang#73670 (Add `format_args_capture` feature) - rust-lang#73693 (Use exhaustive match in const_prop.rs) - rust-lang#73845 (Use &raw in A|Rc::as_ptr) - rust-lang#73861 (Create E0768) - rust-lang#73881 (Standardize bibliographic citations in rustc API docs) - rust-lang#73925 (Improve comments from rust-lang#72617, as suggested by RalfJung) - rust-lang#73949 ([mir-opt] Fix mis-optimization and other issues with the SimplifyArmIdentity pass) - rust-lang#73984 (Edit docs for rustc_data_structures::graph::scc) - rust-lang#73985 (Fix "getting started" link) - rust-lang#73997 (fix typo) - rust-lang#73999 (Bump mingw-check CI image from Ubuntu 16.04 to 18.04.) Failed merges: - rust-lang#74000 (add `lazy_normalization_consts` feature gate) r? @ghost
r? @RalfJung