Skip to content

Some GlobalCtxt/Session cleanups - #161332

Open
nnethercote wants to merge 4 commits into
rust-lang:mainfrom
nnethercote:GlobalCtxt-Session-cleanups
Open

Some GlobalCtxt/Session cleanups#161332
nnethercote wants to merge 4 commits into
rust-lang:mainfrom
nnethercote:GlobalCtxt-Session-cleanups

Conversation

@nnethercote

@nnethercote nnethercote commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

View all comments

Details in individual commits.

r? @Zalathar

To `QuerySystem`, next to `query_vtables`. It's a better spot for it.
@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 18, 2026
@nnethercote

Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 18, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 18, 2026
@rust-bors

rust-bors Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 269c121 (269c121db841542a1520014d2f5f8f5c306b93cb)
Base parent: e71c0f1 (e71c0f1e3395b10a8c331317be1a5c107bdf7b2e)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (269c121): comparison URL.

Overall result: ❌ regressions - 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 rustc-perf
@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.2% [0.1%, 0.4%] 41
Regressions ❌
(secondary)
0.2% [0.0%, 0.5%] 39
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.1%, 0.4%] 41

Max RSS (memory usage)

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

Cycles

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

Binary size

Results (secondary -0.0%)

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)
-0.0% [-0.0%, -0.0%] 12
All ❌✅ (primary) - - 0

Bootstrap: 456.919s -> 458.093s (0.26%)
Artifact size: 398.99 MiB -> 399.07 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 Aug 19, 2026
@nnethercote

Copy link
Copy Markdown
Contributor Author

Gee whiz, doing tcx.sess.prof instead of tcx.prof is a measurable slowdown. I'll take out that change.

@nnethercote
nnethercote force-pushed the GlobalCtxt-Session-cleanups branch from a5315fa to 2872fd6 Compare August 19, 2026 02:14
@nnethercote

Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 19, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 19, 2026
@rust-bors

rust-bors Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: aeb7e24 (aeb7e24b02316d91850f36e7fccf6501e06e92c3)
Base parent: e71c0f1 (e71c0f1e3395b10a8c331317be1a5c107bdf7b2e)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (aeb7e24): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (primary 1.8%, secondary -7.3%)

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

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

Cycles

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

Binary size

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

Bootstrap: 456.919s -> 456.535s (-0.08%)
Artifact size: 398.99 MiB -> 399.00 MiB (0.00%)

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Aug 19, 2026
@nnethercote
nnethercote marked this pull request as ready for review August 19, 2026 08:38
@rustbot

rustbot commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

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

@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 Aug 19, 2026
@nnethercote

Copy link
Copy Markdown
Contributor Author

LLM disclosure: the suggestions for these changes came from an LLM's analysis. I made all the code and text changes myself.

Comment thread compiler/rustc_middle/src/ty/context.rs
@Zalathar

Copy link
Copy Markdown
Member

Yeah, these all look good.

r=me with or without my suggested comment.

This commit moves the eight cache fields in `GlobalCtxt` into a single
type, just to provide some logical grouping and to reduce the number of
fields within `GlobalCtxt`.
It makes sense next to `QuerySystem::side_effects`, and this enables the
use of `DepNodeIndex` for the values instead of the type-erased `u32`.
@nnethercote
nnethercote force-pushed the GlobalCtxt-Session-cleanups branch from 2872fd6 to c55f5a3 Compare August 19, 2026 11:23
@nnethercote

Copy link
Copy Markdown
Contributor Author

@bors r=Zalathar

@rust-bors

rust-bors Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

📌 Commit c55f5a3 has been approved by Zalathar

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 Aug 19, 2026
@Zalathar

Copy link
Copy Markdown
Member

Perf ended up neutral after backing out the regressions.

@bors rollup=maybe

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 19, 2026
…anups, r=Zalathar

Some `GlobalCtxt`/`Session` cleanups

Details in individual commits.

r? @Zalathar
rust-bors Bot pushed a commit that referenced this pull request Aug 19, 2026
…uwer

Rollup of 16 pull requests

Successful merges:

 - #159071 ([PAC] Encoder and hash (1/8))
 - #161277 (bootstrap: Move all non-module items out of the crate root)
 - #161332 (Some `GlobalCtxt`/`Session` cleanups)
 - #161344 (Update the `rustc-perf` submodule)
 - #150931 (rustdoc: Always document `#[repr(transparent)]` if `#[rustc_pub_transparent]` is applied)
 - #160582 (Add `remove hidden_glob_reexports item breaks downstream` test)
 - #160876 (remove unwrap from write_mir_fn_graphviz)
 - #160927 (Enhance EII UI tests)
 - #161070 (fix arm homogeneous aggregate ABI)
 - #161236 (Download auto jobs in citool in parallel)
 - #161254 (Reserve capacity for 3% anon nodes)
 - #161283 (Tighten the language used for documenting `TargetOptions::llvm_abiname`)
 - #161291 (Rename `ProjectionPredicate` and `TraitPredicate`)
 - #161299 (Remove a bunch of unnecessary explicit lifetimes)
 - #161307 (make ARM maintainers pingable)
 - #161308 (Add regression test for rustc diagnostic to recognize variables in match guards)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 19, 2026
…anups, r=Zalathar

Some `GlobalCtxt`/`Session` cleanups

Details in individual commits.

r? @Zalathar
rust-bors Bot pushed a commit that referenced this pull request Aug 19, 2026
…uwer

Rollup of 16 pull requests

Successful merges:

 - #159071 ([PAC] Encoder and hash (1/8))
 - #161068 (Ensure TLS accesses don't call the global allocator through panic (part 3) )
 - #161332 (Some `GlobalCtxt`/`Session` cleanups)
 - #161344 (Update the `rustc-perf` submodule)
 - #150931 (rustdoc: Always document `#[repr(transparent)]` if `#[rustc_pub_transparent]` is applied)
 - #160582 (Add `remove hidden_glob_reexports item breaks downstream` test)
 - #160876 (remove unwrap from write_mir_fn_graphviz)
 - #160927 (Enhance EII UI tests)
 - #161070 (fix arm homogeneous aggregate ABI)
 - #161236 (Download auto jobs in citool in parallel)
 - #161254 (Reserve capacity for 3% anon nodes)
 - #161283 (Tighten the language used for documenting `TargetOptions::llvm_abiname`)
 - #161291 (Rename `ProjectionPredicate` and `TraitPredicate`)
 - #161299 (Remove a bunch of unnecessary explicit lifetimes)
 - #161307 (make ARM maintainers pingable)
 - #161308 (Add regression test for rustc diagnostic to recognize variables in match guards)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 19, 2026
…anups, r=Zalathar

Some `GlobalCtxt`/`Session` cleanups

Details in individual commits.

r? @Zalathar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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. T-rustdoc Relevant to the rustdoc 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