Rework all inlining attribute labels with consistent decisions #36
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_key
where inlining into the API caller can be highly beneficial for out of order execution reasons.Debug::fmt
implementations.#[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.