Rollup of 10 perf-sensitive pull requests - #160506
Open
JonathanBrouwer wants to merge 23 commits into
Open
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
Contributor
Author
Contributor
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 4, 2026
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-*
Contributor
|
⌛ Trying commit d1cef67 with merge 9854f45… To cancel the try build, run the command Workflow: https://github.com/rust-lang/rust/actions/runs/30910262357 |
Contributor
Author
|
This is a rollup of 10 perf-sensitive pull requests, because the queue of them got a bit too large |
Member
|
@bors p=10 scheduling |
Contributor
|
⌛ Testing commit d1cef67 with merge 1ed2df6... Workflow: https://github.com/rust-lang/rust/actions/runs/30913371220 |
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 4, 2026
…uwer Rollup of 10 perf-sensitive pull requests Successful merges: - #157281 (perf: skip irrelevant foreign impls when building the specialization graph) - #159403 (Next steps for FnDef binder changes (instantiate most FnDef binders)) - #159763 (Optimize crate resolution for large workspace) - #160033 (Speed up `EverInitializedPlaces`) - #160268 (perf: store the fulfillment engine inline in ObligationCtxt) - #160317 (perf: Cache already-checked types in the privacy visitor) - #160399 (interpret: skip deref-projection validity checks when they are not needed) - #160451 (Deduplicate target and host filesearch) - #160453 (Add fast path to `escape_string_symbol`) - #160454 (Add offload guard flags to typeck to prevent perf regressions)
Contributor
|
If this succeeds, it will be the greenest rollup in the history of the observable universe. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Successful merges:
EverInitializedPlaces#160033 (Speed upEverInitializedPlaces)escape_string_symbol#160453 (Add fast path toescape_string_symbol)r? @ghost
Create a similar rollup