Skip to content

Rollup of 10 perf-sensitive pull requests - #160506

Open
JonathanBrouwer wants to merge 23 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-9ScDW58
Open

Rollup of 10 perf-sensitive pull requests#160506
JonathanBrouwer wants to merge 23 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-9ScDW58

Conversation

@JonathanBrouwer

Copy link
Copy Markdown
Contributor

Successful merges:

r? @ghost

Create a similar rollup

xmakro and others added 23 commits June 10, 2026 19:38
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
@rust-bors rust-bors Bot added the rollup A PR which is a rollup label Aug 4, 2026
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Aug 4, 2026
@JonathanBrouwer JonathanBrouwer changed the title Rollup of 10 pull requests Rollup of 10 perf-sensitive pull requests Aug 4, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Contributor Author

@bors r+ p=5

Trying commonly failed jobs
@bors try jobs=dist-various-1,test-various,x86_64-gnu-aux,x86_64-gnu-llvm-21-3,x86_64-msvc-1,aarch64-apple,x86_64-mingw-1,i686-msvc-*

@rust-bors

rust-bors Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

📌 Commit d1cef67 has been approved by JonathanBrouwer

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 10. This pull request will be tested once the tree is reopened.

Reason for tree closure: manually handling queue due to backlog

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 4, 2026
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-*
@rust-bors

rust-bors Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

⌛ Trying commit d1cef67 with merge 9854f45

To cancel the try build, run the command @bors try cancel.

Workflow: https://github.com/rust-lang/rust/actions/runs/30910262357

@JonathanBrouwer

Copy link
Copy Markdown
Contributor Author

This is a rollup of 10 perf-sensitive pull requests, because the queue of them got a bit too large
See #t-infra > Tree ops @ 💬 for context

@Kobzol

Kobzol commented Aug 4, 2026

Copy link
Copy Markdown
Member

@bors p=10

scheduling

@rust-bors

rust-bors Bot commented Aug 4, 2026

Copy link
Copy Markdown
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)
@panstromek

Copy link
Copy Markdown
Contributor

If this succeeds, it will be the greenest rollup in the history of the observable universe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants