-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Always inline atomic primitives #68155
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
Conversation
Atomic primitves are supposed to control the way the processor interacts with data but they're not supposed to have any noticeable on program control flow, but they do. Without turning them into `#inline(always)` they will ultimately end up in dev builds which has a severe impact on performance and binary size especially on embedded platforms. Signed-off-by: Daniel Egger <daniel@eggers-club.de>
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @KodrAus (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Let me expand a bit further on the specific problem I'm seeing. Consider one of the simplest programs one can write for an embedded target:
Compiling in dev mode for a
As can be seen
|
This indicates that -O0 codegen of these functions is bad (unsurprising), but I don't see any evidence that these |
@rkruppe In my experience For the
Somehow it should be possible to stay true to the promise that these primitives only affect the compiler but do not change the program flow. |
For reference, here's a disassembly of generated binary: https://gist.github.com/therealprof/fd82057b9b2f0a9f440a91833700af50 |
@rkruppe I've been looking into the code generated by the |
Just another data point regarding the |
This is with the
|
Closing this non-actionable PR for discussion in #68208. |
Atomic primitves are supposed to control the way the processor interacts
with data but they're not supposed to have any noticeable on program
control flow, but they do. Without turning them into
#inline(always)
they will ultimately end up in dev builds which has a severe impact on
performance and binary size especially on embedded platforms.
Signed-off-by: Daniel Egger daniel@eggers-club.de