Skip to content

New solver opts for diesel (part 3) - #165160

Merged
rust-bors[bot] merged 5 commits into
rust-lang:mainfrom
nnethercote:diesel-opts-3
Nov 2, 2026
Merged

rust-bors[bot] merged 5 commits into
rust-lang:mainfrom
nnethercote:diesel-opts-3

Conversation

@nnethercote

@nnethercote nnethercote commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

A sequel to #163981 and #164234. These ones mostly relate to allocations. Details in individual commits.

Local measurements:

solver         icounts (B)
------         -----------
old            36.4
new (orig)     44.5 (1.22x)
new (this PR)  42.4 (1.16x)

Also some small improvements on a range of other benchmarks.

r? @jdonszelmann

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Oct 29, 2026
@nnethercote

Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 29, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 29, 2026
New solver opts for diesel (part 3)
@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 4f26521 (4f26521093dc3d11b878b8f464dbd082553cf1e6)
Base parent: 92b5b8c (92b5b8c87c61b20adc9001b41baf587634a74734)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (4f26521): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.3% [0.2%, 0.4%] 12
Improvements ✅
(primary)
-0.1% [-0.2%, -0.1%] 4
Improvements ✅
(secondary)
-1.4% [-4.4%, -0.1%] 38
All ❌✅ (primary) -0.1% [-0.2%, -0.1%] 4

Max RSS (memory usage)

Results (primary -3.9%, secondary 3.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
7.4% [5.0%, 8.6%] 4
Improvements ✅
(primary)
-3.9% [-3.9%, -3.9%] 1
Improvements ✅
(secondary)
-0.8% [-0.9%, -0.8%] 3
All ❌✅ (primary) -3.9% [-3.9%, -3.9%] 1

Cycles

Results (secondary -1.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.9% [1.7%, 4.5%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.7% [-7.5%, -2.4%] 12
All ❌✅ (primary) - - 0

Binary size

Results (primary -0.2%, secondary -0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.2%, -0.0%] 32
Improvements ✅
(secondary)
-0.1% [-0.3%, -0.0%] 44
All ❌✅ (primary) -0.2% [-0.2%, -0.0%] 32

Bootstrap: 484.843s -> 489.287s (0.92%)
Artifact size: 406.61 MiB -> 409.03 MiB (0.60%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 30, 2026
@nnethercote

Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 30, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 30, 2026
New solver opts for diesel (part 3)
@rust-bors

rust-bors Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 5018116 (50181163cd9f89d9f09e11f71ab14761f7d89ef1)
Base parent: 92b5b8c (92b5b8c87c61b20adc9001b41baf587634a74734)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (5018116): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.2% [0.1%, 0.4%] 5
Improvements ✅
(primary)
-0.2% [-0.2%, -0.1%] 8
Improvements ✅
(secondary)
-1.7% [-4.3%, -0.1%] 32
All ❌✅ (primary) -0.2% [-0.2%, -0.1%] 8

Max RSS (memory usage)

Results (primary -4.6%, secondary -1.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-4.6% [-4.6%, -4.6%] 1
Improvements ✅
(secondary)
-1.7% [-2.3%, -1.1%] 2
All ❌✅ (primary) -4.6% [-4.6%, -4.6%] 1

Cycles

Results (primary 2.8%, secondary -3.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.8% [2.8%, 2.8%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.1% [-4.0%, -2.2%] 13
All ❌✅ (primary) 2.8% [2.8%, 2.8%] 1

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 484.843s -> 482.182s (-0.55%)
Artifact size: 406.61 MiB -> 406.66 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 30, 2026
@nnethercote

Copy link
Copy Markdown
Contributor Author

LLM disclosure: some of the optimization ideas came from LLM analysis. I wrote the code and text myself.

@nnethercote
nnethercote marked this pull request as ready for review October 30, 2026 07:07
@rustbot

rustbot commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

jdonszelmann is currently at their maximum review capacity.
They may take a while to respond.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 30, 2026
@rustbot

rustbot commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

@rust-bors

rust-bors Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 09ac7ab has been approved by jdonszelmann

It is now in the queue for this repository.

@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 Oct 30, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors rollup=iffy
Making a rollup of perf sensitive prs

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 30, 2026
…zelmann

New solver opts for diesel (part 3)

A sequel to rust-lang#163981 and rust-lang#164234. These ones mostly relate to allocations. Details in individual commits.

Local measurements:
```
solver         icounts (B)
------         -----------
old            36.4
new (orig)     44.5 (1.22x)
new (this PR)  42.4 (1.16x)
```
Also some small improvements on a range of other benchmarks.

r? @jdonszelmann
rust-bors Bot pushed a commit that referenced this pull request Oct 30, 2026
…uwer

Rollup of 7 perf-sensitive pull requests

Successful merges:

 - #163339 (MIR move elimination [5/6]: Storage reconstruction)
 - #163525 (Move lang item collection to the resolver)
 - #163928 (do not prefer trivially true candidates with `-Znext-solver` )
 - #164341 (Expand an early return case in `coerce_unsized`)
 - #164484 (Use adaptive sparse encoding for metadata tables)
 - #164607 (destringlyfy lint infrastructure)
 - #165160 (New solver opts for diesel (part 3))

> [!WARNING]
> This rollup conflicts with pending auto build #165178 and may need to be recreated if the pending build succeeds.
rust-bors Bot pushed a commit that referenced this pull request Oct 31, 2026
…uwer

Rollup of 7 perf-sensitive pull requests

Successful merges:

 - #163339 (MIR move elimination [5/6]: Storage reconstruction)
 - #163525 (Move lang item collection to the resolver)
 - #163928 (do not prefer trivially true candidates with `-Znext-solver` )
 - #164341 (Expand an early return case in `coerce_unsized`)
 - #164484 (Use adaptive sparse encoding for metadata tables)
 - #164607 (destringlyfy lint infrastructure)
 - #165160 (New solver opts for diesel (part 3))

> [!WARNING]
> This rollup conflicts with pending auto build #165178 and may need to be recreated if the pending build succeeds.
rust-bors Bot pushed a commit that referenced this pull request Oct 31, 2026
…uwer

Rollup of 7 perf-sensitive pull requests

Successful merges:

 - #163339 (MIR move elimination [5/6]: Storage reconstruction)
 - #163525 (Move lang item collection to the resolver)
 - #163928 (do not prefer trivially true candidates with `-Znext-solver` )
 - #164341 (Expand an early return case in `coerce_unsized`)
 - #164484 (Use adaptive sparse encoding for metadata tables)
 - #164607 (destringlyfy lint infrastructure)
 - #165160 (New solver opts for diesel (part 3))

> [!WARNING]
> This rollup conflicts with pending auto build #165178 and may need to be recreated if the pending build succeeds.
@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 31, 2026
@rust-bors

This comment has been minimized.

We still use `ThinVec<I::GenericArg>` in `GoalStalledOn`, where the
narrowness of the type is important. But using `Vec<I::GenericArg>`
elsewhere is a perf win for `CanonicalizerState::variables`, which has
`clone_from` called on it a lot. (`Vec::clone_from` is better optimized
than `ThinVec::clone_from`.)
Returning requires `take`, which means the next user of
`CanonicalizerState` has to allocate a new vec. `finalize` has two
callers, but only one of them needs `variables`. This commit makes it so
that single caller just clones the vec out of `CanonicalizerState`
itself.
Currently, `InferCtxt` has a `CanonicalizerState` that gets reused by
each canonicalizer. This gives a good amount of reuse, but we can
increase it by moving the state to `GlobalCaches`. And we actually need
a vector of `CanonicalizerState`, though it can only get multiple
elements if we are using multiple threads.
`compute_query_response_instantiation_values_in_universe` computes an
`opt_values` vector but then only sometimes consults the contents. This
commit makes it lazy for a small perf win.
`CanonicalVarValues::instantiate` builds a `var_values` using a closure
to generate each element. That closure is passed the under-construction
`var_values`, which is unusual. This commit renames the parameters in
the closures to `prev_var_values` to make this unusual behaviour more
obvious.

The commit looks bigger than it really is because of formatting changes.
@rustbot

rustbot commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@nnethercote

Copy link
Copy Markdown
Contributor Author

I rebased.

@bors r=jdonszelmann

@rust-bors

rust-bors Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

📌 Commit d3dca22 has been tentatively approved by jdonszelmann

It will be put into the queue for this repository once PR CI succeeds.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 2, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 2, 2026
…uwer

Rollup of 2 pull requests

Successful merges:

 - #165140 (More derive(Debug) cleanups for structs)
 - #165160 (New solver opts for diesel (part 3))
@rust-bors
rust-bors Bot merged commit c96d25f into rust-lang:main Nov 2, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Nov 2, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 2, 2026
Rollup merge of #165160 - nnethercote:diesel-opts-3, r=jdonszelmann

New solver opts for diesel (part 3)

A sequel to #163981 and #164234. These ones mostly relate to allocations. Details in individual commits.

Local measurements:
```
solver         icounts (B)
------         -----------
old            36.4
new (orig)     44.5 (1.22x)
new (this PR)  42.4 (1.16x)
```
Also some small improvements on a range of other benchmarks.

r? @jdonszelmann
@nnethercote
nnethercote deleted the diesel-opts-3 branch November 2, 2026 10:11
BenMac31 pushed a commit to graphide-oss/rust-analyzer that referenced this pull request Nov 2, 2026
…uwer

Rollup of 2 pull requests

Successful merges:

 - rust-lang/rust#165140 (More derive(Debug) cleanups for structs)
 - rust-lang/rust#165160 (New solver opts for diesel (part 3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer 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.

5 participants