Skip to content

Simplify the cache_on_disk_if modifier to just cache_on_disk#154576

Open
Zalathar wants to merge 3 commits intorust-lang:mainfrom
Zalathar:cache-on-disk
Open

Simplify the cache_on_disk_if modifier to just cache_on_disk#154576
Zalathar wants to merge 3 commits intorust-lang:mainfrom
Zalathar:cache-on-disk

Conversation

@Zalathar
Copy link
Copy Markdown
Member

Thanks to #154304, there is now only one remaining query with a non-trivial cache-on-disk condition (check_liveness). But prior experiments at #153441 (comment) indicate that check_liveness can also be made non-disk-caching with little or no measurable effect.

This PR takes advantage of those facts to replace the cache_on_disk_if modifier with a simpler cache_on_disk modifier:

  • When combined with separate_provide_extern, only values for “local” keys are cached to disk.
  • For any other query with cache_on_disk, values are cached to disk unconditionally.

r? nnethercote (or compiler)

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

cc @Zoxc @zetanumbers

@Zalathar
Copy link
Copy Markdown
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 Mar 30, 2026
Simplify the `cache_on_disk_if` modifier to just `cache_on_disk`
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 30, 2026
@zetanumbers
Copy link
Copy Markdown
Contributor

Ok, that's good

@zetanumbers
Copy link
Copy Markdown
Contributor

@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-review Status: Awaiting review from the assignee but also interested parties. labels Mar 30, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Mar 30, 2026

💔 Test for 72527f8 failed: CI

@lqd
Copy link
Copy Markdown
Member

lqd commented Mar 30, 2026

timeout
@bors try

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 30, 2026
Simplify the `cache_on_disk_if` modifier to just `cache_on_disk`
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Mar 30, 2026

☀️ Try build successful (CI)
Build commit: 5a1a969 (5a1a969187f4afe604cb916bc5740a09c5062f4b, parent: cf7da0b7277cad05b79f91b60c290aa08a17a6f0)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (5a1a969): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

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.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@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.8% [0.8%, 0.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.2% [-0.6%, -0.1%] 8
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 1.4%)

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

mean range count
Regressions ❌
(primary)
1.4% [1.4%, 1.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.4% [1.4%, 1.4%] 1

Cycles

Results (secondary -1.6%)

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.2% [2.2%, 2.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.4% [-5.4%, -5.4%] 1
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 483.836s -> 485.128s (0.27%)
Artifact size: 394.90 MiB -> 394.80 MiB (-0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 30, 2026
_tcx: TyCtxt<'tcx>,
_key: rustc_middle::queries::$name::Key<'tcx>,
) -> bool {
if !cfg!($cache_on_disk) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you use #[cfg] instead of cfg!?

Alternatively, cfg_select! might make this function nicer.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The cfg_select! version ends up being a bit visually “messier”, but has the benefit of being very explicit about exhaustively listing all possible cases, which seems like an improvement. 👍

This is the only remaining query with a non-trivial `cache_on_disk_if`
condition, but previous perf experiments indicate that it can be removed
entirely, with little or no measurable effect.
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 31, 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.

Queries with both `cache_on_disk` and `separate_provide_extern` will only
disk-cache values for local keys.

Other queries with `cache_on_disk` will disk-cache all values unconditionally.
@Zalathar
Copy link
Copy Markdown
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 31, 2026
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) perf-regression Performance regression. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants