Skip to content

perf: Drop irrelevant caller bounds from query type op keys [-0.16% primary; -21.5% async-trait-heavy] - #79

Draft
xmakro wants to merge 1 commit into
perf/base-0713from
perf/type-op-irrelevant-param-env
Draft

perf: Drop irrelevant caller bounds from query type op keys [-0.16% primary; -21.5% async-trait-heavy]#79
xmakro wants to merge 1 commit into
perf/base-0713from
perf/type-op-irrelevant-param-env

Conversation

@xmakro

@xmakro xmakro commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Query type ops are keyed on a canonicalized parameter environment. A where clause that mentions the implementing type, such as the Self: 'a that async trait desugaring produces, therefore gives every impl a distinct key, and the work behind that key is repeated per impl instead of shared once. The effect is concentrated in MIR borrow checking, and it is not specific to regions: a bound with no regions at all shows the same behaviour, while a bound that is the same in every impl does not.

When the goal itself mentions no parameters, a caller bound that does mention one cannot apply to it, and outlives bounds can never apply either, since candidate assembly keeps only trait clauses. In that case the empty environment is substituted into the query key. This happens at the single point where every query type op canonicalizes, and the original environment is kept for region instantiation, so only the key changes.

tests/ui passes.

@xmakro xmakro changed the title perf: Drop irrelevant caller bounds from query type op keys perf: Drop irrelevant caller bounds from query type op keys [-0.16% primary; -21.5% async-trait-heavy] Aug 1, 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