-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Provide safe wrappers for single-threaded memory fence intrinsics #41091
Comments
Add safe wrapper for atomic_compilerfence intrinsics This PR adds a proposed safe wrapper for the `atomic_singlethreadfence_*` intrinsics introduced by [RFC #888](rust-lang/rfcs#888). See #41091 for further discussion.
This is the tracking issue for https://doc.rust-lang.org/nightly/std/sync/atomic/fn.compiler_fence.html. |
@rfcbot fcp merge Hasn't changed in quite awhile and seems straightforward to stabilize! |
Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
It seems mildly strange to me that these would live in |
I am okay with the placement. As a data point, C++ has their equivalent std::atomic_signal_fence in |
@sfackler: I completely agree, and had the same reservation when I first implemented this. But as you say yourself, it's unclear where else this somewhat weird function should go. |
Yeah, given that C++ sticks it in |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
…=alexcrichton stabilized compiler_fences (fixes rust-lang#41091) I did not know what to proceed with "unstable-book" entry. The feature would no longer be unstable so I have deleted it. If it was the wrong call I'll revert it (unfortunately his case is not described in the CONTRIBUTING.md).
…=alexcrichton stabilized compiler_fences (fixes rust-lang#41091) I did not know what to proceed with "unstable-book" entry. The feature would no longer be unstable so I have deleted it. If it was the wrong call I'll revert it (unfortunately his case is not described in the CONTRIBUTING.md).
…=alexcrichton stabilized compiler_fences (fixes rust-lang#41091) I did not know what to proceed with "unstable-book" entry. The feature would no longer be unstable so I have deleted it. If it was the wrong call I'll revert it (unfortunately his case is not described in the CONTRIBUTING.md).
RFC #888 introduced single-threaded (i.e., compiler-only) memory fence intrinsics, and was implemented in #24833.
The RFC explicitly does not add safe wrappers for these new barriers, and states
While the argument is sound, authors of low-level concurrency libraries are often very concerned about the performance overhead of full-blown memory fences when a simple compiler barrier will do. The current design requires authors of such libraries to either require a nightly compiler (to use intrinsics), or to fall back to the old
workaround (which for the time being also requires nightly due to
feature(asm)
).I propose adding in a safe wrapper around these compiler barrier intrinsics alongside
fence
after all, with name and documentation that clearly indicates how that function differs from whatfence
provides. PR incoming shortly.The text was updated successfully, but these errors were encountered: