Skip to content

Conversation

@Zalathar
Copy link
Member

For queries that never incremental-cache to disk, we can represent that fact with None (i.e. a null function pointer) in their vtables, and avoid having to generate stub functions that do nothing.

(There is no decrease in vtable size; we just go from 3/8 padding bytes to 4/8 padding bytes.)

There should be no change to compiler output.

@rustbot rustbot added the A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) label Jan 27, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 27, 2026

r? @nnethercote

rustbot has assigned @nnethercote.
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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 27, 2026
@Zalathar
Copy link
Member 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 Jan 27, 2026
Make some load-from-disk function pointers optional in query vtables
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 27, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 27, 2026

☀️ Try build successful (CI)
Build commit: ce4f469 (ce4f4699f1f8b8f6e8d98a52c720c124da15017c, parent: 78df2f92de1da3601d967dc8beb9f9cea267e45f)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ce4f469): comparison URL.

Overall result: ❌✅ regressions and 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.1% [0.0%, 0.1%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.0%] 5
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -1.9%, secondary -2.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)
-1.9% [-1.9%, -1.9%] 1
Improvements ✅
(secondary)
-2.1% [-2.9%, -1.7%] 3
All ❌✅ (primary) -1.9% [-1.9%, -1.9%] 1

Cycles

Results (primary 2.1%, secondary 1.0%)

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

mean range count
Regressions ❌
(primary)
2.1% [2.1%, 2.1%] 1
Regressions ❌
(secondary)
4.4% [3.0%, 5.4%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.5% [-3.8%, -3.1%] 3
All ❌✅ (primary) 2.1% [2.1%, 2.1%] 1

Binary size

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

Bootstrap: 472.873s -> 473.545s (0.14%)
Artifact size: 385.68 MiB -> 383.69 MiB (-0.52%)

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

@nnethercote nnethercote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple of questions below.

View changes since this review

query_state: std::mem::offset_of!(QueryStates<'tcx>, $name),
query_cache: std::mem::offset_of!(QueryCaches<'tcx>, $name),
cache_on_disk: |tcx, key| ::rustc_middle::query::cached::$name(tcx, key),
will_cache_on_disk_for_key_fn: should_ever_cache_on_disk!([$($modifiers)*] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you've added a should_ever_cache_on_disk! call. Was that missing previously?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it looks like should_ever_cache_on_disk! now returns Some/None at all use sites. I think it could be simplified accordingly, to look like hash_result!.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you've added a should_ever_cache_on_disk! call. Was that missing previously?

Yes. Previously, for queries that don't cache to disk, rustc_macros would generate a stub function that always returns false. With this PR, rustc_macros doesn't generate that function at all for non-disk-cached queries, and we use should_ever_cache_on_disk! to avoid needing it.

Copy link
Member Author

@Zalathar Zalathar Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it looks like should_ever_cache_on_disk! now returns Some/None at all use sites. I think it could be simplified accordingly, to look like hash_result!.

I find it easier to think of should_ever_cache_on_disk! as a compile-time if expression, with the two arms expanding to whatever makes sense at the call site.

So I think moving Some/None into the macro would be a false simplification; it's better to have them clearly visible at the call site.

@nnethercote
Copy link
Contributor

@bors r+ rollup=iffy

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 28, 2026

📌 Commit 414535b has been approved by nnethercote

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 Jan 28, 2026
@Zalathar
Copy link
Member Author

I expect I will probably have to rebase this after #151666.

@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 Jan 28, 2026
@rust-bors

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Jan 28, 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.

@Zalathar
Copy link
Member Author

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-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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants