-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
valtree performance tuning #136593
base: master
Are you sure you want to change the base?
valtree performance tuning #136593
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
[perf] try to mitigate regression in fast reject for `ty::Value` rust-lang#136318 (comment) r? ghost
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (95bc439): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary -2.0%, secondary -1.1%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (secondary 2.5%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 778.541s -> 779.446s (0.12%) |
dc8caa3
to
bc51bb2
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
[perf] try to mitigate regression in fast reject for `ty::Value` rust-lang#136318 (comment) r? ghost
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (9e91e50): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary -0.9%, secondary -2.5%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary -2.1%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 780.473s -> 782.144s (0.21%) |
bc51bb2
to
cd733ad
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
[perf] try to mitigate regression in fast reject for `ty::Value` rust-lang#136318 (comment) r? ghost
This comment has been minimized.
This comment has been minimized.
cd733ad
to
c7c2f1c
Compare
c7c2f1c
to
e252733
Compare
☔ The latest upstream changes (presumably #136762) made this pull request unmergeable. Please resolve the merge conflicts. |
e252733
to
d6f5175
Compare
ty::Value
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
valtree performance tuning Summary: This PR makes type checking of code with many type-level constants faster. After rust-lang#136180 was merged, we observed a small perf regression (rust-lang#136318 (comment)). This happened because that PR introduced additional copies in the fast reject code path for consts, which is very hot for certain crates: https://github.com/rust-lang/rust/blob/6c1d960d88dd3755548b3818630acb63fa98187e/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. A less invasive alternative that I considered is simply avoiding copies introduced by rust-lang#136180 and comparing the valtrees it in-place (see commit: rust-lang@9e91e50 / perf results: rust-lang#136593 (comment)), however that was still measurably slower than interning.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (fdc99c9): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary -1.2%, secondary 2.3%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary -3.1%, secondary 2.7%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 779.273s -> 777.952s (-0.17%) |
d6f5175
to
88beb48
Compare
Some changes occurred in cc @BoxyUwU The rustc-dev-guide subtree was changed. If this PR only touches the dev guide consider submitting a PR directly to rust-lang/rustc-dev-guide otherwise thank you for updating the dev guide with your changes. cc @BoxyUwU, @jieyouxu, @Kobzol Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred to the CTFE machinery cc @rust-lang/wg-const-eval |
r? @oli-obk |
☔ The latest upstream changes (presumably #136905) made this pull request unmergeable. Please resolve the merge conflicts. |
88beb48
to
b722d5d
Compare
HIR ty lowering was modified cc @fmease |
@bors r+ |
Summary: This PR makes type checking of code with many type-level constants faster.
After #136180 was merged, we observed a small perf regression (#136318 (comment)). This happened because that PR introduced additional copies in the fast reject code path for consts, which is very hot for certain crates:
rust/compiler/rustc_type_ir/src/fast_reject.rs
Lines 486 to 487 in 6c1d960
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 #136180 and comparing the valtrees it in-place (see commit: 9e91e50 / perf results: #136593 (comment)), 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.