-
Notifications
You must be signed in to change notification settings - Fork 22
Rework all inlining attribute labels with consistent decisions #36
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
Open
xacrimon
wants to merge
11
commits into
djc:main
Choose a base branch
from
xacrimon:joel/no-hint-inline-cold-path
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…'t hint inlining on serialize or visit_seq
…e/uncommon fns in lru_cache.rs and linked_hash_set.rs
… functions that called from many more public facing API-layer methods
djc
reviewed
Oct 15, 2025
| } | ||
|
|
||
| impl<T: Hash + Eq> LinkedHashSet<T, DefaultHashBuilder> { | ||
| #[inline] |
Owner
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's not obvious to me that this should be counted as expensive, large or uncommon, so I guess the commit message doesn't make much sense to me?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the last PR of the trio of changes I wanted that I've had on my own fork for a little while now. I suspect that inlining attributes have been added over time hapazardly to random functions without really considering the affects or checking the result is desirable.
So, I've gone through and looked at every method in the public API and it's dissassembly with various opt levels ("3", "s", "z", 0) and function by function tweaked things to so that only code that needs to be inlined for performance is, and appropriate amounts are outlined at the various levels. This also included some miscellanous fixes like swapping the hasher wrapper methods to
#[inline(always)]as not inlining generates slower and larger code on every single opt level outside except 0.Generally, the changes and though process can be summed up as:
clear()orshrink_to_fit, call overhead for these is not a real concern but the compile drawbacks of including and recompiling those extra #[inline] functions in every codegen unit is.#[inline]on outer API layer functions that are mostly just a shim over a couple of internal fnshashlink.hash_keywhere inlining into the API caller can be highly beneficial for out of order execution reasons.Debug::fmtimplementations.#[inline]is avoided and applied randomly just prevents LLVMs heuristics from making good decisions.My testing of this in real world applications hasn't shown any performance regression, but has improved build time, total generated LLVM IR lines and binary size noticably on my test binary projects. I also haven't been able to create a microbenchmark that regresses on these changes. I haven't really observed any changes above statistical error.