rust/compiler/rustc_hir_analysis/src
bors c241e14650 Auto merge of #136593 - lukas-code:ty-value-perf, r=oli-obk
valtree performance tuning

Summary: This PR makes type checking of code with many type-level constants faster.

After https://github.com/rust-lang/rust/pull/136180 was merged, we observed a small perf regression (https://github.com/rust-lang/rust/pull/136318#issuecomment-2635562821). This happened because that PR introduced additional copies in the fast reject code path for consts, which is very hot for certain crates: 6c1d960d88/compiler/rustc_type_ir/src/fast_reject.rs (L486-L487)

This PR improves the performance again by properly interning the valtrees so that copying and comparing them becomes faster. This will become especially useful with `feature(adt_const_params)`, so the fast reject code doesn't have to do a deep compare of the valtrees.

Note that we can't just compare the interned consts themselves in the fast reject, because sometimes `'static` lifetimes in the type are be replaced with inference variables (due to canonicalization) on one side but not the other.

A less invasive alternative that I considered is simply avoiding copies introduced by https://github.com/rust-lang/rust/pull/136180 and comparing the valtrees it in-place (see commit: 9e91e50ac5 / perf results: https://github.com/rust-lang/rust/pull/136593#issuecomment-2642303245), however that was still measurably slower than interning.

There are some minor regressions in secondary benchmarks: These happen due to changes in memory allocations and seem acceptable to me. The crates that make heavy use of valtrees show no significant changes in memory usage.
2025-02-13 15:27:30 +00:00
..
check Auto merge of #136965 - jhpratt:rollup-bsnqvmf, r=jhpratt 2025-02-13 11:45:11 +00:00
coherence Rollup merge of #136107 - dingxiangfei2009:coerce-pointee-wellformed, r=compiler-errors 2025-02-11 02:53:42 +01:00
collect Rollup merge of #136806 - adwinwhite:cycle-in-pretty-print-rpitit, r=compiler-errors 2025-02-12 20:09:59 -05:00
errors Use a different hir type for patterns in pattern types than we use in match patterns 2025-02-03 08:18:30 +00:00
hir_ty_lowering Auto merge of #136593 - lukas-code:ty-value-perf, r=oli-obk 2025-02-13 15:27:30 +00:00
impl_wf_check Fix a comment typo. 2025-01-31 08:28:14 +11:00
outlives Remove an unnecessary loop label. 2025-01-31 08:28:28 +11:00
variance Remove xform submodule. 2025-01-31 08:28:28 +11:00
autoderef.rs Rename structurally_normalize to structurally_normalize_ty 2025-01-22 07:04:53 +00:00
bounds.rs Merge HostPolarity and BoundConstness 2024-10-30 16:23:16 +00:00
check_unused.rs Remove #[macro_use] extern crate tracing from rustc_hir_analysis. 2024-08-30 17:14:59 +10:00
collect.rs Explain that in paths generics can't be set on both the enum and the variant 2025-02-11 23:30:07 +00:00
constrained_generic_params.rs Remove #[macro_use] extern crate tracing from rustc_hir_analysis. 2024-08-30 17:14:59 +10:00
delegation.rs Rustfmt 2025-02-08 22:12:13 +00:00
errors.rs Implement lint for definition site item shadowing too 2025-02-13 05:45:53 +00:00
hir_wf_check.rs visit_x_unambig 2025-01-23 06:01:36 +00:00
impl_wf_check.rs Rename tcx.ensure() to tcx.ensure_ok() 2025-02-01 12:38:54 +11:00
lib.rs Split out the extern_system_varargs feature 2025-02-12 19:57:45 -08:00