Skip to content

Use &C::Key less in queries.#153464

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
nnethercote:less-ref-Key
Mar 8, 2026
Merged

Use &C::Key less in queries.#153464
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
nnethercote:less-ref-Key

Conversation

@nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Mar 6, 2026

View all comments

Currently we use a mix of C::Key and &C::Key parameters. The former is more common and a bit nicer, so convert some of the latter. This results in less converting between the two types, and fewer sigils.

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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. labels Mar 6, 2026
@nnethercote
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 6, 2026
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 6, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 6, 2026

☀️ Try build successful (CI)
Build commit: 2abf06c (2abf06ccb2341f2676797960ae2a6174f5c7ce7a, parent: 69370dc4a8862b8401615a2a7b950704ba66c495)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2abf06c): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@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
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 0.4%, secondary 0.6%)

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

mean range count
Regressions ❌
(primary)
2.2% [1.2%, 3.3%] 5
Regressions ❌
(secondary)
2.0% [0.5%, 3.1%] 4
Improvements ✅
(primary)
-1.9% [-3.1%, -0.8%] 4
Improvements ✅
(secondary)
-2.2% [-2.4%, -2.1%] 2
All ❌✅ (primary) 0.4% [-3.1%, 3.3%] 9

Cycles

Results (primary 0.4%, secondary 3.0%)

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

mean range count
Regressions ❌
(primary)
2.0% [1.9%, 2.2%] 2
Regressions ❌
(secondary)
3.0% [2.6%, 3.4%] 2
Improvements ✅
(primary)
-3.0% [-3.0%, -3.0%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.4% [-3.0%, 2.2%] 3

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 482.035s -> 481.544s (-0.10%)
Artifact size: 397.04 MiB -> 395.05 MiB (-0.50%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 6, 2026
@nnethercote nnethercote marked this pull request as ready for review March 6, 2026 06:15
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 6, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 6, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 6, 2026

r? @JohnTitor

rustbot has assigned @JohnTitor.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, query-system
  • compiler, query-system expanded to 69 candidates
  • Random selection from 15 candidates

@nnethercote
Copy link
Contributor Author

r? @Zalathar

@bors rollup

@rustbot rustbot assigned Zalathar and unassigned JohnTitor Mar 6, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 6, 2026

Zalathar is not on the review rotation at the moment.
They may take a while to respond.

@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@nnethercote
Copy link
Contributor Author

I rebased.

@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@nnethercote
Copy link
Contributor Author

I extended this a little, so let's make sure it's still perf-neutral.

@bors try @rust-timer queue

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 8, 2026
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 8, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 8, 2026

☀️ Try build successful (CI)
Build commit: f47e635 (f47e6356236da892d981d12ce4cd4fa45d770b48, parent: e370b60cf2b0d3e4b55923ec1558c5b5f8970cfb)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f47e635): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@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.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 1.2%)

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

mean range count
Regressions ❌
(primary)
1.2% [1.0%, 1.5%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.2% [1.0%, 1.5%] 2

Cycles

Results (primary 1.8%, 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)
1.8% [1.8%, 1.8%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.7% [-1.7%, -1.7%] 1
All ❌✅ (primary) 1.8% [1.8%, 1.8%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 485.77s -> 479.714s (-1.25%)
Artifact size: 395.01 MiB -> 397.04 MiB (0.51%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 8, 2026
@nnethercote
Copy link
Contributor Author

Perf-neutral.

@bors rollup

@rust-bors

This comment has been minimized.

@Zalathar
Copy link
Member

Zalathar commented Mar 8, 2026

I wasn't very excited by this as a cleanup, but I guess having key be a non-reference in cache_on_disk_if { ... } makes it net-positive overall.

And if I guess if perf is neutral there's no particular reason to not pass copyable values by value.

r=me after a rebase.

Currently we use a mix of `C::Key` and `&C::Key` parameters. The former
is more common and a bit nicer, so convert some of the latter. This
results in less converting between the two types, and fewer sigils.
@rustbot
Copy link
Collaborator

rustbot commented Mar 8, 2026

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
Contributor Author

having key be a non-reference in cache_on_disk_if { ... } makes it net-positive overall.

That was the motivation, along with having all the fns in the query vtable be consistent. And then it spread to a bunch of the plumbing/execution/job functions too.

@nnethercote
Copy link
Contributor Author

I rebased.

@bors r=Zalathar rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 8, 2026

📌 Commit face186 has been approved by Zalathar

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 Mar 8, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 8, 2026
Use `&C::Key` less in queries.

Currently we use a mix of `C::Key` and `&C::Key` parameters. The former is more common and a bit nicer, so convert some of the latter. This results in less converting between the two types, and fewer sigils.
@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 8, 2026

⌛ Testing commit face186 with merge 2754da3...

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

rust-bors bot pushed a commit that referenced this pull request Mar 8, 2026
Use `&C::Key` less in queries.



Currently we use a mix of `C::Key` and `&C::Key` parameters. The former is more common and a bit nicer, so convert some of the latter. This results in less converting between the two types, and fewer sigils.
@JonathanBrouwer
Copy link
Contributor

@bors yield
Yielding to enclosing rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 8, 2026

Auto build was cancelled. Cancelled workflows:

The next pull request likely to be tested is #153576.

rust-bors bot pushed a commit that referenced this pull request Mar 8, 2026
…uwer

Rollup of 4 pull requests

Successful merges:

 - #153464 (Use `&C::Key` less in queries.)
 - #153553 (Remove the `rustc_data_structures::assert_matches!` re-exports)
 - #153561 (Replace the `try_mark_green` hook with direct calls to `tcx.dep_graph`)
 - #153564 (rendering interpreter OOM as OOM instead of ICE)
@rust-bors rust-bors bot merged commit 38108e1 into rust-lang:main Mar 8, 2026
11 of 12 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 8, 2026
rust-timer added a commit that referenced this pull request Mar 8, 2026
Rollup merge of #153464 - nnethercote:less-ref-Key, r=Zalathar

Use `&C::Key` less in queries.

Currently we use a mix of `C::Key` and `&C::Key` parameters. The former is more common and a bit nicer, so convert some of the latter. This results in less converting between the two types, and fewer sigils.
@nnethercote nnethercote deleted the less-ref-Key branch March 8, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants