optimize: use inline hint instead of inline(always) for enum codecs - #61
Merged
Merged
Conversation
Owner
|
Thank you for the PR. I would like to accept this change, but the comment in the relevant section seems redundant. Could you limit the change to just the |
farhan-syah
force-pushed
the
perf/enum-codec-split
branch
from
August 4, 2026 07:33
bb3156c to
d24a150
Compare
Contributor
Author
Done |
Owner
|
Merged the PR. Thanks! |
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
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.
Fixes #60.
Changes the two derive-generated codec functions from
#[inline(always)]to#[inline]. Every hand-written#[inline(always)]inzerompk/src/impl.rsandzerompk/src/lib.rsis left exactly as it is — those bodies are a few instructions on a hot path and the attribute is right for them.These two are the only sites whose body size is chosen by the user's type rather than by the library. A derived enum decoder grows with the variant count, and forcing it inline means a parent enum that wraps several op enums becomes one
function containing all of their decoders. LLVM's passes are superlinear in function size, so the cost grows far faster than the type does — on the 50-line reproduction in #60, a crate-only rebuild goes from 28.90s to 0.82s.
#[inline]still lets the cost model inline the small cases, which is nearly all of them.Verification
tests/derive.rsare present identically on a pristinemainworktree, so they are not from this change.I did not measure a runtime effect. The change only removes a forcing attribute, so small codecs are still inlined by the cost model.