Skip to content

rustc_type_ir: Optimize sub_root_lookup_table by using SsoHashMap, not HashMap - #166078

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
mikwielgus:sub_root_lookup_table_fxhash_sbo
Nov 20, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
mikwielgus:sub_root_lookup_table_fxhash_sbo

Conversation

@mikwielgus

@mikwielgus mikwielgus commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

sub_root_lookup_table member is a SsoHashMap in
compiler/rustc_infer/src/infer/canonical/canonicalizer.rs, but in rustc_type_ir it has been a bare HashMap. As far as I understand, it's going to likewise almost always have only few elements at most, so let's try to do small-buffer optimization here too by making this struct member a SsoHashMap.

@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 Nov 16, 2026
@rustbot

rustbot commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

r? @fmease

rustbot has assigned @fmease.
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, types
  • compiler, types expanded to 79 candidates
  • Random selection from 22 candidates

@mikwielgus
mikwielgus force-pushed the sub_root_lookup_table_fxhash_sbo branch 2 times, most recently from e712964 to 171bfe2 Compare November 16, 2026 21:12
Comment thread compiler/rustc_type_ir/src/canonical.rs Resolved
@fmease

fmease commented Nov 16, 2026

Copy link
Copy Markdown
Member

@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 Nov 16, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Nov 16, 2026
…r=<try>

rustc_type_ir: Optimize `sub_root_lookup_table` by using `SsoHashMap`, not `HashMap`
@fmease fmease 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 Nov 16, 2026
@rust-bors

rust-bors Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 3283ad0 (3283ad023e20aee1d3524f8610f76b8a8ce39f53)
Base parent: c99bff8 (c99bff8cd92cfc7545121db13506095828082138)

@rust-timer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

…, not `HashMap`

`sub_root_lookup_table` struct member is a `SsoHashMap` in
`compiler/rustc_infer/src/infer/canonical/canonicalizer.rs`, but in
rustc_type_ir it has been a bare `HashMap`. As far as I understand,
it's going to likewise almost always have only few elements at most, so
let's try to do small-buffer optimization here too by making this struct
member a `SsoHashMap`.
@mikwielgus
mikwielgus force-pushed the sub_root_lookup_table_fxhash_sbo branch from 171bfe2 to 3333750 Compare November 16, 2026 22:20
@rust-timer

Copy link
Copy Markdown

Finished benchmarking commit (3283ad0): comparison URL.

Overall result: ✅ improvements - 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

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

Max RSS (memory usage)

Results (primary -1.6%, 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)
- - 0
Regressions ❌
(secondary)
0.6% [0.4%, 0.7%] 3
Improvements ✅
(primary)
-1.6% [-2.4%, -0.7%] 2
Improvements ✅
(secondary)
-0.8% [-0.8%, -0.8%] 1
All ❌✅ (primary) -1.6% [-2.4%, -0.7%] 2

Cycles

Results (secondary -0.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.4% [0.4%, 0.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.7% [-0.9%, -0.5%] 4
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 465.336s -> 466.46s (0.24%)
Artifact size: 406.17 MiB -> 406.19 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 16, 2026

@fmease fmease left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@bors r+ rollup=iffy note=perf-improv-likely-real

View changes since this review

@rust-bors

rust-bors Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 3333750 has been approved by fmease

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 Nov 19, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 19, 2026
…xhash_sbo, r=fmease

rustc_type_ir: Optimize `sub_root_lookup_table` by using `SsoHashMap`, not `HashMap`

`sub_root_lookup_table` member is a `SsoHashMap` in
`compiler/rustc_infer/src/infer/canonical/canonicalizer.rs`, but in rustc_type_ir it has been a bare `HashMap`. As far as I understand, it's going to likewise almost always have only few elements at most, so let's try to do small-buffer optimization here too by making this struct member a `SsoHashMap`.
rust-bors Bot pushed a commit that referenced this pull request Nov 19, 2026
…uwer

Rollup of 16 pull requests

Successful merges:

 - #166078 (rustc_type_ir: Optimize `sub_root_lookup_table` by using `SsoHashMap`, not `HashMap`)
 - #165934 (Avoid using Terminator:None in simplify_cfg)
 - #166050 (Use attribute parser for lang attributes in `LateResolutionVisitor`)
 - #166117 (Remove ebadf handling from stdio)
 - #166119 (Avoid an ICE on re-exports of private imports without a DefId)
 - #165094 (reflection: doc attributes from adts, fields, and variants)
 - #165216 (Clearer diagnostics when `&FnOnce` was provided when `FnOnce` was expected)
 - #165694 (view-types: make sure view types are !Sized)
 - #165883 (Report a recursion limit error instead of delaying a bug in RPITIT collector)
 - #165971 (fix: non-deterministic temporary object paths in linker maps)
 - #166064 (Add const generic transmute min support)
 - #166136 (Move ub_checks() inside the const_eval_select branch.)
 - #166166 (Don't recover if not allowed in `parse_seq_to_before_tokens`)
 - #166176 (compiletest: Move all code out of the crate root)
 - #166185 (simd-test: Fix cfg syntax in the test macro)
 - #166194 (std: Unstably constify `std::process::abort`)

Failed merges:

 - #166150 (Reflection: refactor Type and TypeKind)
 - #166160 (refactor CTFE-specific intrinsics to different file)
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added the merged-by-bors This PR was explicitly merged by bors. label Nov 20, 2026
@rust-bors rust-bors Bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Nov 20, 2026
@rust-bors

rust-bors Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: fmease
Duration: 3h 9m 40s
Pushing 4b5350e to main...

@rust-bors
rust-bors Bot merged commit 4b5350e into rust-lang:main Nov 20, 2026
15 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 20, 2026
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

A job failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling rustls-webpki v0.103.16
   Compiling ureq v3.4.0
   Compiling citool v0.1.0 (/home/runner/work/rust/rust/src/ci/citool)
    Finished `release` profile [optimized] target(s) in 50.85s
     Running `target/release/citool post-merge-report 6905905bb7727fd0f9223f5fdc9ad4e62236d5a2 4b5350e87e487aed08ab2f9f0160a4b2616438bc`
Downloading metrics of job test-aarch64-gnu
Downloading metrics of job test-aarch64-gnu-debug
Downloading metrics of job test-arm-android
Downloading metrics of job test-armhf-gnu
Downloading metrics of job dist-aarch64-linux
Downloading metrics of job dist-android
Did not find metrics for job `dist-android` at `6905905bb7727fd0f9223f5fdc9ad4e62236d5a2`: io: Connection reset by peer (os error 104).
Maybe it was newly added?
Downloading metrics of job dist-arm-linux-gnueabi
Downloading metrics of job dist-arm-linux-musl
Downloading metrics of job dist-armhf-linux
Downloading metrics of job dist-armv7-linux
Downloading metrics of job dist-i586-gnu-i586-i686-musl
Downloading metrics of job dist-i686-linux
Downloading metrics of job dist-loongarch64-linux
Downloading metrics of job dist-loongarch64-musl
Downloading metrics of job dist-ohos-aarch64
Downloading metrics of job dist-ohos-armv7
Downloading metrics of job dist-ohos-x86_64
Downloading metrics of job dist-powerpc-linux
Error: io: Connection reset by peer (os error 104)
##[error]Process completed with exit code 1.
Post job cleanup.

@rust-timer

Copy link
Copy Markdown

Finished benchmarking commit (4b5350e): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.4%, -0.2%] 7
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -0.1%, 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)
1.6% [1.2%, 2.0%] 2
Regressions ❌
(secondary)
1.6% [0.4%, 2.9%] 4
Improvements ✅
(primary)
-1.3% [-2.1%, -0.8%] 3
Improvements ✅
(secondary)
-1.1% [-3.4%, -0.5%] 6
All ❌✅ (primary) -0.1% [-2.1%, 2.0%] 5

Cycles

Results (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)
- - 0
Regressions ❌
(secondary)
0.5% [0.4%, 0.6%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.7% [-1.0%, -0.5%] 3
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 458.85s -> 458.821s (-0.01%)
Artifact size: 405.28 MiB -> 405.37 MiB (0.02%)

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

Labels

merged-by-bors This PR was explicitly merged by bors. 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