about summary refs log tree commit diff
path: root/library/std/src/sys/unix/env.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-12-14 04:04:10 +0000
committerbors <bors@rust-lang.org>2023-12-14 04:04:10 +0000
commitd23e1a689426638a5146c204e09278433c509610 (patch)
tree66e0c0b557ffd9f33b4f7012f52c5934d0efbc50 /library/std/src/sys/unix/env.rs
parente6d1b0ec9859e6f5c29aaa3b6525fb625bf354ad (diff)
parentaa36c35296561db171939a6dc95279214fca3775 (diff)
downloadrust-d23e1a689426638a5146c204e09278433c509610.tar.gz
rust-d23e1a689426638a5146c204e09278433c509610.zip
Auto merge of #117749 - aliemjay:perf-canon-cache, r=lcnr
cache param env canonicalization

Canonicalize ParamEnv only once and store it. Then whenever we try to canonicalize `ParamEnvAnd<'tcx, T>` we only have to canonicalize `T` and then merge the results.

Prelimiary results show ~3-4% savings in diesel and serde benchmarks.

Best to review commits individually. Some commits have a short description.

Initial implementation had a soundness bug (https://github.com/rust-lang/rust/pull/117749#issuecomment-1840453387) due to cache invalidation:
- When canonicalizing `Ty<'?0>` we first try to resolve region variables in the current InferCtxt which may have a constraint `?0 == 'static`. This means that we register `Ty<'?0> => Canonical<Ty<'static>>` in the cache, which is obviously incorrect in another inference context.
- This is fixed by not doing region resolution when canonicalizing the query *input* (vs. response), which is the only place where ParamEnv is used, and then in a later commit we *statically* guard against any form of inference variable resolution of the cached canonical ParamEnv's.

r? `@ghost`
Diffstat (limited to 'library/std/src/sys/unix/env.rs')
0 files changed, 0 insertions, 0 deletions