Skip to content

DepNode use improvements#154076

Draft
nnethercote wants to merge 3 commits intorust-lang:mainfrom
nnethercote:DepNode-improvements
Draft

DepNode use improvements#154076
nnethercote wants to merge 3 commits intorust-lang:mainfrom
nnethercote:DepNode-improvements

Conversation

@nnethercote
Copy link
Contributor

No description provided.

The call chain for a non-incremental query includes the following
functions:

- execute_query_non_incr_inner (assert!)
- try_execute_query (assert!)
- execute_job_non_incr (assert!)

And likewise for an incremental query:

- execute_query_incr_inner (assert!)
- try_execute_query (assert!)
- execute_job_incr (expect)

That is five distinct functions. Every one of them has an `assert!` or
`expect` call that checks that the dep-graph is/is not enabled as
expected. Three cheers for defensive programming but this feels like
overkill, particularly when `execute_job{,_non_incr,_incr}` each have a
single call site.

This commit removes the assertions in `execute_query_*` and
`try_execute_query`, leaving a check in each of the `execute_job_*`
functions.
Currently we only compute it when necessary -- sometimes in
`check_if_ensure_can_skip_execution`, sometimes in
one of two places in `execute_job_incr` -- and pass around
`Option<DepNode>` to allow this.

This commit changes things so we always compute it up front for
incremental queries. The performance cost is negligible and it
simplifies things.
- `check_if_ensure_can_skip_execution` can be made simpler, returning a
  bool and eliminating the need for `EnsureCanSkip`.
- `execute_job_incr` no longer uses two slightly different methods to
  create a `DepNode` (`get_or_insert_with` vs `unwrap_or_else`).
As of the previous commit, the `dep_node` argument fully determines if
it's a non-incremental or incremental query, so `INCR` is no longer
needed.
@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 19, 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 19, 2026
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 19, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 19, 2026

☀️ Try build successful (CI)
Build commit: bc93a15 (bc93a15a42df606eeda0f7aeaeb1ce878b78320e, parent: fd0c901b00ee1e08a250039cdb90258603497e20)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (bc93a15): 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.1%, 0.6%] 16
Regressions ❌
(secondary)
0.4% [0.1%, 0.6%] 34
Improvements ✅
(primary)
-0.1% [-0.2%, -0.1%] 6
Improvements ✅
(secondary)
-0.2% [-0.3%, -0.0%] 9
All ❌✅ (primary) 0.2% [-0.2%, 0.6%] 22

Max RSS (memory usage)

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

Cycles

Results (primary 2.3%)

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

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

Binary size

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

Bootstrap: 481.003s -> 479.861s (-0.24%)
Artifact size: 396.91 MiB -> 394.32 MiB (-0.65%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 19, 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-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.

3 participants