-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Use #[inline(always)]
on trivial UnsafeCell methods
#83858
Conversation
UnsafeCell is the standard building block for shared mutable data structures. UnsafeCell should add zero overhead compared to using raw pointers directly. Some reports suggest that debug builds, or even builds at opt-level 1, may not always be inlining its methods. Mark the methods as `#[inline(always)]`, since once inlined the methods should result in no actual code other than field accesses.
(rust-highfive has picked a reviewer for you, use r? to override) |
I'd expect this to be performance-neutral for optimized code (including @bors try @rust-timer queue |
⌛ Trying commit 37498a1 with merge 22cffcc1b41f3fa0b95ea1add2096cfa12b43681... |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
Do you have evidence to suggest this actually fixes the inlining problems? It seems odd that LLVM is not inlining such trivial functions (they're generic so should be available for that), so maybe a deeper investigation is worthwhile, though it doesn't necessarily need to block this PR. Cc @rust-lang/lang |
Er that was meant to be @rust-lang/wg-llvm , sorry lang team :) |
Both |
☀️ Try build successful - checks-actions |
Queued 22cffcc1b41f3fa0b95ea1add2096cfa12b43681 with parent 5b0ab79, future comparison URL. |
Finished benchmarking try commit (22cffcc1b41f3fa0b95ea1add2096cfa12b43681): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
Hm, interesting. This seems somewhat unexpected, and may not be a good fit for Rust -- I guess we could tag things always_inline (which IIRC is still just a hint?) in O1 more eagerly? This seems good to merge in the meantime though. @bors r+ |
📌 Commit 37498a1 has been approved by |
☀️ Test successful - checks-actions |
UnsafeCell is the standard building block for shared mutable data
structures. UnsafeCell should add zero overhead compared to using raw
pointers directly.
Some reports suggest that debug builds, or even builds at opt-level 1,
may not always be inlining its methods. Mark the methods as
#[inline(always)]
, since once inlined the methods should result in noactual code other than field accesses.