Fast-reject method probe candidates by self type head [in -0.51% batch]#52
Draft
xmakro wants to merge 1 commit into
Draft
Fast-reject method probe candidates by self type head [in -0.51% batch]#52xmakro wants to merge 1 commit into
xmakro wants to merge 1 commit into
Conversation
Every method-call probe runs a by-value candidate pass before the autoref passes, and for the overwhelmingly common &self/&mut self methods that pass scans all name-matched candidates, paying for a snapshot, fresh args and normalization per candidate just to fail the self type unification. Compare the simplified head of the receiver against the simplified head of the method's declared self parameter first; two concrete, different heads cannot unify. Bare Self, aliases and non-method items fall through to the full check, and path-mode (UFCS) probes are exempt since they relate against the impl self type instead.
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.
Every method-call probe runs a by-value candidate pass before the autoref passes, and for the overwhelmingly common &self/&mut self methods that pass scans all name-matched candidates, paying for a snapshot, fresh args for the impl, and normalization per candidate just to fail the self type unification. Compare the simplified head of the receiver against the simplified head of the method's declared self parameter first; two concrete, different heads cannot unify, so the whole per-candidate machinery is skipped.
Bare Self, aliases and non-method items fall through to the full check. Path-mode (UFCS) probes are exempt: they relate against the impl self type, not the method's self parameter — the builtin Debug derive expands to exactly such qualified calls, so getting this wrong fails bootstrap immediately.
Measurement context: the four sibling batch-4 branches were measured together on top of the earlier branches (ThinLTO stage2, glibc allocator, instructions:u, full scenario): combined -0.51% geomean, syn check -1.18%, ripgrep check -1.12%, hyper check -0.87%, cargo check -0.77%, serde check -0.52%, 9 of 15 cells improved >= 0.25%, 0 regressed. Full tests/ui passes with the whole stack (only the 7 pre-existing triaged diffs). The compiler bootstraps itself with all of it. The whole 4-batch stack measures -3.42% geomean with every one of the 15 cells improved.