Rollup of 10 perf-sensitive pull requests - #160506
Conversation
By keeping a map from hash to crate number.
Every ObligationCtxt heap-allocated its fulfillment engine as a Box<dyn TraitEngine>, making it the single largest allocation site in the compiler (161k allocations on a syn check build, created per candidate probe in method resolution among others). The solver choice is a per-session constant and both engine types are small, so store them inline in a two-variant enum with static dispatch. The enum's TraitEngine impl needs both FromSolverError bounds, which ripples to the generic impl blocks and two generic users; the concrete error types used everywhere implement both. The boxed engine remains for the per-body typeck root fulfillment context.
Currently it tracks a bit for every `Init`, but it only uses the tracked data for locals. This means it is tracking data for projections that is unused. This commit shrinks the domain to only track data for `Local`s, going from `MixedBitSet<InitIndex>` to `DenseBitSet<Local>`. This does regress the error messages in one test: liveness-assign-imm-local-notes.rs. The next commit will fix that. The commit also removes some `debug` statements which probably haven't seen use in a long time. They can be re-added easily if anyone needs them in the future.
This commit fixes the error message regression in the previous commit by recomputing flow information at error-reporting time. `is_local_ever_initialized` is replaced in two ways. - In `check_access_permissions`: by the new `first_reaching_init` function which picks the first init that can reach the error location along a path that doesn't cross `StorageDead(local)`. - In `add_used_mut`: by a simple `contains` test.
Co-Authored-By: Matthieu M <matthieum.147192@gmail.com>
…n-impls, r=jackh726 perf: skip irrelevant foreign impls when building the specialization graph Skip foreign non-blanket impls that can't overlap any local impl when building the specialization graph. The call site showed up when profiling and this PR leads to a mean -1.5% instructions perf improvement, see rust-lang#157281 (comment)
…li-obk Next steps for FnDef binder changes (instantiate most FnDef binders) This change is a part of the ongoing effort to clean up binder/turbofishing behavior in the compiler (rust-lang#156581). This PR instantiates binders that were previously created via `ty::Binder::dummy()` with meaningfully bound vars. r? oli-obk > Call me Turbofishmael. Some years ago- never mind how long precisely- having little or no money in my purse, and nothing particular to interest me in C++, I thought I would sail about a little and see the rusty part of the world.
Optimize crate resolution for large workspace By keeping a map from hash to crate number.
…jgillot Speed up `EverInitializedPlaces` By simplifying its domain. Details in individual commits. r? @cjgillot
…r=nnethercote perf: store the fulfillment engine inline in ObligationCtxt Every `ObligationCtxt` allocated its fulfillment engine on the heap as a `Box<dyn TraitEngine>`. This was the single largest allocation site in the compiler: 161k allocations on a `syn` check build (measured with DHAT). `ObligationCtxt`s are created in hot paths, for example once per candidate probe during method resolution. The allocation is easy to avoid. Which solver is used never changes during a compilation session, and both engine types are small (the obligation forest allocates its own storage separately). So this PR stores the engine directly inside `ObligationCtxt`, in a two-variant enum. Calls now go through a match on that enum instead of virtual dispatch. The enum's `TraitEngine` impl needs both `FromSolverError` bounds, so a few generic impl blocks and two generic users now need both bounds as well. The concrete error types used in practice already implement both, so nothing else changes for callers. The typeck root fulfillment context keeps the boxed engine; it is created once per function body, so the allocation does not matter there.
…e-cache, r=petrochenkov perf: Cache already-checked types in the privacy visitor The privacy checker walks the full type of every expression and pattern in a module, re-walking the same type once per node it appears on. This caches the types that walked clean (no privacy error) and skips them next time. A walk's result depends only on the interned type and the fixed module being checked, so a type that walks clean once walks clean everywhere. Only clean walks are cached, so nothing is lost: a type that errors is never cached and still fires at every span, and no dep-graph edges are dropped since the full walk already ran once in the same query.
… r=oli-obk interpret: skip deref-projection validity checks when they are not needed Trying to claw back the perf regression from rust-lang#160012. We could also, like, skip the entire check in const-eval when we don't care about validity. But the slowdown will also affect Miri so I want to first try what we can do without doing less UB checking.
Deduplicate target and host filesearch I was looking into preprocessing the search directories somehow, so that both host and target don't have to scan them. However, it would be a bit annoying, because they don't share the tlib path. But then I noticed that the code already used `Arc` for `SearchPath`, which was essentially the same optimization, which made sense before rust-lang#158823. But after that PR, it doesn't make sense to put `SearchPath` into `Arc`, because it doesn't really do anything, and the complex logic moved into `FileSearch`. So this PR puts that under `Arc`, to avoid doing duplicated work in the common case, where `host == target`. r? petrochenkov
Add fast path to `escape_string_symbol` Discussed in rust-lang#159916. So far used the manual escaping variant. CC @matthieu-m r? the8472
Add offload guard flags to typeck to prevent perf regressions Fixes perf regression in rust-lang#158693 r? @ZuseZ4
Rollup of 10 perf-sensitive pull requests try-job: dist-various-1 try-job: test-various try-job: x86_64-gnu-aux try-job: x86_64-gnu-llvm-21-3 try-job: x86_64-msvc-1 try-job: aarch64-apple try-job: x86_64-mingw-1 try-job: i686-msvc-*
This comment has been minimized.
This comment has been minimized.
|
This is a rollup of 10 perf-sensitive pull requests, because the queue of them got a bit too large |
|
@bors p=10 scheduling |
This comment has been minimized.
This comment has been minimized.
|
If this succeeds, it will be the greenest rollup in the history of the observable universe. |
|
📌 Perf builds for each rolled up PR:
previous master: 0b63defc8f In the case of a perf regression, run the following command for each PR you suspect might be the cause: |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 0b63def (parent) -> 1ed2df6 (this PR) Test differencesShow 42 test diffs42 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 1ed2df61a19042f231709eb05d032ae9e2cb2084 --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (1ed2df6): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Our benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -1.9%, secondary -2.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -3.7%, secondary -6.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.1%, secondary 0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 489.577s -> 489.825s (0.05%) |
|
@rustbot label: +perf-regression-triaged |
Successful merges:
EverInitializedPlaces#160033 (Speed upEverInitializedPlaces)escape_string_symbol#160453 (Add fast path toescape_string_symbol)r? @ghost
Create a similar rollup