Skip to content

Remove const FLAGS.#152791

Draft
nnethercote wants to merge 2 commits intorust-lang:mainfrom
nnethercote:rm-const-FLAGS
Draft

Remove const FLAGS.#152791
nnethercote wants to merge 2 commits intorust-lang:mainfrom
nnethercote:rm-const-FLAGS

Conversation

@nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Feb 18, 2026

View all comments

The performance wins provided by these types are meagre, and I don't think they justify the code complexity they introduce.

r? @Zalathar

@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 Feb 18, 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 Feb 18, 2026
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 18, 2026
@Zalathar
Copy link
Member

I wonder if this PR's approach will preserve some of the benefits of static flags via inlining. It's certainly nicer than having FLAGS everywhere.

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 18, 2026

☀️ Try build successful (CI)
Build commit: 744269b (744269beec5ae0238f5da62161b8168c2e7f8956, parent: 8387095803f21a256a9a772ac1f9b41ed4d5aa0a)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (744269b): comparison URL.

Overall result: ❌ regressions - 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.3% [0.1%, 0.9%] 42
Regressions ❌
(secondary)
0.4% [0.1%, 1.0%] 78
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.1%, 0.9%] 42

Max RSS (memory usage)

Results (primary 2.4%, secondary -0.2%)

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

mean range count
Regressions ❌
(primary)
2.4% [1.8%, 3.6%] 3
Regressions ❌
(secondary)
3.3% [1.8%, 6.0%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.6% [-4.0%, -3.2%] 3
All ❌✅ (primary) 2.4% [1.8%, 3.6%] 3

Cycles

Results (primary 3.0%, secondary 3.3%)

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

mean range count
Regressions ❌
(primary)
3.0% [2.4%, 4.1%] 6
Regressions ❌
(secondary)
3.3% [2.1%, 4.5%] 29
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.0% [2.4%, 4.1%] 6

Binary size

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

Bootstrap: 480.396s -> 481.316s (0.19%)
Artifact size: 397.88 MiB -> 397.75 MiB (-0.03%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Feb 18, 2026
@rust-bors

This comment has been minimized.

@nnethercote
Copy link
Contributor Author

Just enough of a regression that it's hard to justify, alas. I see now that SemiDynamicQueryDispatcher and QueryVTable could be merged if FLAGS went away.

Relatedly, I found the following functions take a FLAGS generic param but don't actually use it:

  • mk_cycle
  • handle_cycle_error
  • cycle_error
  • wait_for_query
  • try_load_from_disk_and_cache_in_memory
  • query_key_hash_verify
  • try_load_from_on_disk_cache_inner

They can be changed to take a QueryVTable instead of a SemiDynamicQueryDispatcher, though then some methods on the latter need to be moved to the former in such a way that's it's not a uniform facade type.

@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 Feb 19, 2026
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 19, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 19, 2026

☀️ Try build successful (CI)
Build commit: 06d3be4 (06d3be4e20551ccb3f23a19b0d08dabb3542e3fa, parent: e0cb264b814526acb82def4b5810e394a2ed294f)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (06d3be4): 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.3% [0.2%, 0.5%] 14
Regressions ❌
(secondary)
0.3% [0.1%, 0.6%] 33
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.4% [-0.5%, -0.1%] 8
All ❌✅ (primary) 0.3% [0.2%, 0.5%] 14

Max RSS (memory usage)

Results (secondary -5.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)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.5% [-5.5%, -5.5%] 1
All ❌✅ (primary) - - 0

Cycles

Results (primary -2.8%, secondary -3.2%)

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)
-2.8% [-2.8%, -2.8%] 1
Improvements ✅
(secondary)
-3.2% [-3.2%, -3.2%] 1
All ❌✅ (primary) -2.8% [-2.8%, -2.8%] 1

Binary size

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

Bootstrap: 487.064s -> 481.364s (-1.17%)
Artifact size: 397.85 MiB -> 395.69 MiB (-0.54%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 19, 2026
`SemiDynamicQueryDispatcher` is just a `QueryVTable` wrapper with an
additional `const FLAGS: QueryFlags` generic parameter that contains
three booleans. This arrangement exists as a performance optimization.
But the performance effects are very small and it adds quite a bit of
complexity to an already overly-complex part of the codebase. If it
didn't exist and somebody proposed adding it and asked me to review, I
almost certainly wouldn't approve it.

This commit removes it. The three booleans in `QueryFlags` are moved
into `QueryVTable` The non-trivial methods of
`SemiDynamicQueryDispatcher` become methods of `QueryVTable`.
It's now `query_vtable` because its return type changed. And thanks to
the previous commit it can be manually inlined in several places. (The
only remaining calls to it are in `make_dep_kind_vtable_for_query`,
which are more challenging to remove.)
@rustbot
Copy link
Collaborator

rustbot commented Feb 20, 2026

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

@nnethercote
Copy link
Contributor Author

nnethercote commented Feb 20, 2026

Looking at icounts for primary benchmarks, there are only 14 runs where the regression is considered significant, and the worst case is 0.5%. 8 of the 14 are doc builds, not sure why those are more affected, but they're arguably less important that non-doc builds.

The story for secondary benchmark is pretty similar.

Overall, the perf effects of this optimization is just really underwhelming. I don't think it's worth it, especially in part of the code that is already very complex and there is lots of ongoing work to reduce complexity.

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 20, 2026

☔ The latest upstream changes (presumably #152747) made this pull request unmergeable. Please resolve the merge conflicts.

@Zalathar
Copy link
Member

Overall, the perf effects of this optimization is just really underwhelming. I don't think it's worth it, especially in part of the code that is already very complex and there is lots of ongoing work to reduce complexity.

When I first tried to get rid of FLAGS, I felt discouraged by the small-but-measurable perf regression.

But every time I run into how annoying it is to deal with having FLAGS everywhere, that regression starts to look more and more like something we should accept for the big simplicity win.

@Zalathar
Copy link
Member

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

5 participants

Comments