Skip to content

Fast-reject method probe candidates by self type head [in -0.51% batch]#52

Draft
xmakro wants to merge 1 commit into
perf/base-0713from
perf/probe-self-head-reject
Draft

Fast-reject method probe candidates by self type head [in -0.51% batch]#52
xmakro wants to merge 1 commit into
perf/base-0713from
perf/probe-self-head-reject

Conversation

@xmakro

@xmakro xmakro commented Jul 13, 2026

Copy link
Copy Markdown
Owner

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.

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.
@xmakro xmakro changed the title Fast-reject method probe candidates by self type head Fast-reject method probe candidates by self type head [in -0.51% batch] Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant