Skip to content

Remove nodes_in_current_session field and related assertions#154283

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Zoxc:rem-nodes_in_current_session
Apr 22, 2026
Merged

Remove nodes_in_current_session field and related assertions#154283
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Zoxc:rem-nodes_in_current_session

Conversation

@Zoxc
Copy link
Copy Markdown
Contributor

@Zoxc Zoxc commented Mar 24, 2026

View all comments

This removes the nodes_in_current_session field and related assertions. These are enabled if -Z incremental-verify-ich is passed or debug_assertions is on. Historically these have been useful to catch query keys with improper HashStable impls which lead to collisions.

We currently also check for duplicate nodes when loading the dep graph. This check is more complete as it covers the entire dep graph and is enabled by default. It doesn't provide a query key for a collision however. This check is also delayed to the next incremental session.

We also have the verify_query_key_hashes which is also enabled if -Z incremental-verify-ich is passed or debug_assertions is on. This checks for dep node conflicts in each query cache and provides 2 conflicting keys if present.

I think these remaining checks are sufficient and so we can remove nodes_in_current_session.

@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 Mar 24, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 24, 2026

r? @jdonszelmann

rustbot has assigned @jdonszelmann.
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, incremental, query-system
  • compiler, incremental, query-system expanded to 69 candidates
  • Random selection from 12 candidates

@Zoxc
Copy link
Copy Markdown
Contributor Author

Zoxc commented Mar 24, 2026

@rust-log-analyzer

This comment has been minimized.

@Zoxc Zoxc force-pushed the rem-nodes_in_current_session branch from 922660c to 267d6cf Compare March 24, 2026 00:49
@jdonszelmann
Copy link
Copy Markdown
Contributor

This looks reasonable to me, but I'm no expert on the query system. Going to defer to @nnethercote (or someone else if that's better)

r? @nnethercote

@rustbot rustbot assigned nnethercote and unassigned jdonszelmann Apr 2, 2026
Copy link
Copy Markdown
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 one nit below.

View changes since this review

}

#[cfg(debug_assertions)]
fn record_edge(
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.

I'd prefer to keep this entire function cfg(debug_assertions), and then likewise at the call sites. It makes it clearer that it's all debug-only, and avoids the need for the underscores on the parameter names.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was thinking of just converting this to cfg!.

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.

#[cfg] makes the call sites clearer.

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.

Why?
I basically always prefer if cfg! to #[cfg] when technically possible because it doesn't hide the configured-out code from type checker and other later passes.

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.

Fine, whatever, just do cfg! then.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should I do it in this PR? I was thinking of making a follow-up PR.

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.

Just do it here, save the trouble of filing a follow-up

@nnethercote nnethercote 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 Apr 5, 2026
@Zoxc Zoxc force-pushed the rem-nodes_in_current_session branch from 267d6cf to 14b2173 Compare April 12, 2026 16:04
@rustbot

This comment has been minimized.

forbidden_edge,
#[cfg(debug_assertions)]
value_fingerprints: Lock::new(IndexVec::from_elem_n(None, new_node_count_estimate)),
value_fingerprints: Lock::new(if cfg!(debug_assertions) {
Copy link
Copy Markdown
Contributor

@nnethercote nnethercote Apr 13, 2026

Choose a reason for hiding this comment

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

View changes since the review

Now we are always doing work that we were only doing in debug builds, because we have fields in the struct that we used to only have in debug builds.

Sorry, I didn't realize that switching to cfg! would cause this. I think this goes too far. I suggest just removing this second commit and going with the original first commit which uses #[cfg(debug_attributes)] within record_edge.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am tempted to add a DebugOnly type so we can have fields only present with debug_assertions, but still get type checking. That would be useful elsewhere too. Would that be sufficient given that the extra work would optimize away?

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.

Not sure I like that, but it would definitely be a separate PR anyway.

@Zoxc Zoxc force-pushed the rem-nodes_in_current_session branch from 14b2173 to 736242c Compare April 21, 2026 02:22
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 21, 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.

@Zoxc Zoxc force-pushed the rem-nodes_in_current_session branch from 736242c to 0add85c Compare April 21, 2026 03:05
@nnethercote
Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 22, 2026

📌 Commit 0add85c 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 22, 2026
rust-bors Bot pushed a commit that referenced this pull request Apr 22, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #154794 (Add on_unmatch_args)
 - #155133 (Document precision considerations of `Duration`-float methods)
 - #154283 (Remove `nodes_in_current_session` field and related assertions)
 - #155374 (rustdoc: fix a few spots where emit isn't respected)
 - #155587 (Immediately feed visibility on DefId creation)
 - #155622 (c-variadic: `va_arg` fixes )
 - #155629 (rustc_public: Add `constness` & `asyncness` in `FnDef`)
 - #155632 (Some metadata cleanups)
 - #155639 (BinOpAssign always returns unit)
 - #155647 (rustc-dev-guide subtree update)
@rust-bors rust-bors Bot merged commit 8bade03 into rust-lang:main Apr 22, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 22, 2026
rust-timer added a commit that referenced this pull request Apr 22, 2026
Rollup merge of #154283 - Zoxc:rem-nodes_in_current_session, r=nnethercote

Remove `nodes_in_current_session` field and related assertions

This removes the `nodes_in_current_session` field and related assertions. These are enabled if `-Z incremental-verify-ich` is passed or `debug_assertions` is on. Historically these have been useful to catch query keys with improper `HashStable` impls which lead to collisions.

We currently also check for duplicate nodes when loading the dep graph. This check is more complete as it covers the entire dep graph and is enabled by default. It doesn't provide a query key for a collision however. This check is also delayed to the next incremental session.

We also have the `verify_query_key_hashes` which is also enabled if `-Z incremental-verify-ich` is passed or `debug_assertions` is on. This checks for dep node conflicts in each query cache and provides 2 conflicting keys if present.

I think these remaining checks are sufficient and so we can remove `nodes_in_current_session`.
@Zoxc Zoxc deleted the rem-nodes_in_current_session branch April 22, 2026 23:52
@Mark-Simulacrum
Copy link
Copy Markdown
Member

@rust-timer build 1a7e42e

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (1a7e42e): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@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.7% [0.0%, 2.0%] 3
Improvements ✅
(primary)
-0.8% [-3.6%, -0.2%] 95
Improvements ✅
(secondary)
-1.3% [-5.3%, -0.0%] 73
All ❌✅ (primary) -0.8% [-3.6%, -0.2%] 95

Max RSS (memory usage)

Results (primary -6.1%, 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)
5.3% [1.4%, 8.2%] 6
Improvements ✅
(primary)
-6.1% [-11.4%, -1.5%] 156
Improvements ✅
(secondary)
-6.6% [-19.8%, -1.3%] 56
All ❌✅ (primary) -6.1% [-11.4%, -1.5%] 156

Cycles

Results (primary -4.6%, secondary -7.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)
3.4% [3.4%, 3.4%] 1
Improvements ✅
(primary)
-4.6% [-13.5%, -2.0%] 70
Improvements ✅
(secondary)
-7.3% [-21.7%, -2.4%] 52
All ❌✅ (primary) -4.6% [-13.5%, -2.0%] 70

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 492.288s -> 492.321s (0.01%)
Artifact size: 394.44 MiB -> 394.35 MiB (-0.02%)

@rustbot rustbot added the perf-regression Performance regression. label Apr 23, 2026
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Apr 24, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#154794 (Add on_unmatch_args)
 - rust-lang/rust#155133 (Document precision considerations of `Duration`-float methods)
 - rust-lang/rust#154283 (Remove `nodes_in_current_session` field and related assertions)
 - rust-lang/rust#155374 (rustdoc: fix a few spots where emit isn't respected)
 - rust-lang/rust#155587 (Immediately feed visibility on DefId creation)
 - rust-lang/rust#155622 (c-variadic: `va_arg` fixes )
 - rust-lang/rust#155629 (rustc_public: Add `constness` & `asyncness` in `FnDef`)
 - rust-lang/rust#155632 (Some metadata cleanups)
 - rust-lang/rust#155639 (BinOpAssign always returns unit)
 - rust-lang/rust#155647 (rustc-dev-guide subtree update)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. 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.

8 participants