You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 28, 2025. It is now read-only.
Auto merge of rust-lang#139576 - davidtwco:paramenv-multiple-fields, r=<try>
split `ParamEnv::caller_bounds` into multiple fields
This patch splits `ParamEnv::caller_bounds` into multiple fields, one for each `ClauseKind`. This is intended to be a performance optimisation, avoiding unnecessary iteration over large `ParamEnv`s when most kinds of clauses aren't relevant in any given context.
I make this change in three steps (reflected in the commits):
1. Changing the interface of `ParamEnv`
- Replace `ParamEnv::caller_bounds` with functions returning iterators over specific kinds of clause, and then updating all users. A `ParamEnv::all_clauses` function, identical in behaviour to `ParamEnv::caller_bounds` remains for the handful of cases where iteration over all clauses is desirable.
2. Interning `ParamEnv`
- In anticipation of changing the internals of `ParamEnv`, to avoid the type growing and to keep it `Copy`, `ParamEnv` is interned, becoming a pointer to `ParamEnvInner`.
3. Changing the internals of `ParamEnv`
- Replacing the `caller_bounds` field with a field for each type of clause and updating the creation of `ParamEnv` to partition a sequence of `Clause`s into the appropriate fields.
This is intended to help improve the performance of rust-lang#137944, which results in many new predicates in the `ParamEnv`, and in particular, lots of new host effect predicates which can't be fast-path'd away. As part of that work, I've experimented with variations on this patch which had worse performance:
- Uninterned `ParamEnv`
- `Box<[Clause<'tcx>]>` fields rather than `Clauses<'tcx>`
- Box<[SpecificPredicateType<'tcx>]>` fields rather than `Clauses<'tcx>`
r? types
0 commit comments