Skip to content

Rewrite rustc_span::symbol::Interner to avoid double hashing#157252

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
heinwol:symbol-Interner-double-hashing
Jun 9, 2026
Merged

Rewrite rustc_span::symbol::Interner to avoid double hashing#157252
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
heinwol:symbol-Interner-double-hashing

Conversation

@heinwol

@heinwol heinwol commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

View all comments

Involves resorting to raw HashTable and writing an ad-hoc IndexMap-like structure, as we cannot get access to raw hashes otherwise.

My local cachegrind profile shows ~ -20_000_000 Ir

r? @petrochenkov

@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 Jun 1, 2026
@rustbot

rustbot commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@petrochenkov

Copy link
Copy Markdown
Contributor

@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 Jun 1, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 1, 2026
Rewrite `rustc_span::symbol::Interner` to avoid double hashing
@petrochenkov petrochenkov removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 1, 2026
@rust-bors

rust-bors Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: e66b004 (e66b0048988e203053f928d27053451bfb56886a, parent: 4804ad7e93e1b31f4605b7083871d0d3d85a2afe)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (e66b004): 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.8% [0.2%, 1.5%] 5
Improvements ✅
(primary)
-0.6% [-0.8%, -0.2%] 6
Improvements ✅
(secondary)
-0.4% [-2.1%, -0.0%] 36
All ❌✅ (primary) -0.6% [-0.8%, -0.2%] 6

Max RSS (memory usage)

Results (primary 1.6%, secondary 1.2%)

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.2%] 4
Regressions ❌
(secondary)
4.0% [1.1%, 10.0%] 9
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.2% [-8.1%, -0.6%] 7
All ❌✅ (primary) 1.6% [1.2%, 2.2%] 4

Cycles

Results (secondary -2.7%)

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

Binary size

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

Bootstrap: 509.892s -> 512.954s (0.60%)
Artifact size: 400.78 MiB -> 400.82 MiB (0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 1, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

The red numbers in include-blob are a noise from LLVM codegen.

@petrochenkov petrochenkov added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 1, 2026
@heinwol

heinwol commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

I've added locking enhancements to reduce contention, maybe this will cause some improvement (or maybe the contrary). Of course, this is only relevant in multithreaded benches, i'm not sure if we can reliably test this.

Also, due to my lack of experience, I'd like a more professional look at whether I have some concurrency bugs. I think I've mitigated the TOCTOU and locking order is deterministic. My benches and tests run fine.

@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_span/src/symbol.rs Outdated
Comment thread compiler/rustc_span/src/symbol.rs Outdated
Comment thread compiler/rustc_span/src/symbol.rs Outdated
Comment thread compiler/rustc_span/src/symbol.rs Outdated
Comment thread compiler/rustc_span/src/symbol.rs Outdated
Comment thread compiler/rustc_span/src/symbol.rs Outdated
Comment thread compiler/rustc_span/src/symbol.rs Outdated
@petrochenkov

Copy link
Copy Markdown
Contributor

I've added locking enhancements to reduce contention, maybe this will cause some improvement (or maybe the contrary). Of course, this is only relevant in multithreaded benches, i'm not sure if we can reliably test this.

Could you remove this change from this PR?
It can be submitted later after the double hashing optimizations merges.

Otherwise LGTM, left some style nits.
@rustbot author

@rustbot rustbot 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 Jun 3, 2026
@rustbot

rustbot commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@heinwol heinwol force-pushed the symbol-Interner-double-hashing branch 2 times, most recently from 5c67961 to ec77a49 Compare June 8, 2026 14:13
Involves resorting to raw `HashTable` and writing an ad-hoc
`IndexMap`-like structure, as we cannot get access to raw hashes
otherwise.

My local cachegrind profile shows ~ -20_000_000 Ir
@heinwol heinwol force-pushed the symbol-Interner-double-hashing branch from ec77a49 to 00d08cb Compare June 8, 2026 14:16
@heinwol

heinwol commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 8, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 8, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 00d08cb has been approved by petrochenkov

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 Jun 8, 2026
@rust-bors

This comment has been minimized.

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

rust-bors Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: petrochenkov
Duration: 4h 2m 11s
Pushing 83b3bfc to main...

@rust-bors rust-bors Bot merged commit 83b3bfc into rust-lang:main Jun 9, 2026
13 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing cb46fbb (parent) -> 83b3bfc (this PR)

Test differences

Show 5 test diffs

Stage 0

  • symbol::tests::interner_get: [missing] -> pass (J0)

Stage 1

  • symbol::tests::interner_get: [missing] -> pass (J1)

Additionally, 3 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 83b3bfc40a9d2fb07dd08a275d80a6ba8a903f18 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-gnu-llvm-22-1: 45m 45s -> 1h 13m (+61.1%)
  2. i686-gnu-2: 1h 41m -> 1h 3m (-37.8%)
  3. x86_64-msvc-ext3: 1h 27m -> 1h 54m (+29.8%)
  4. i686-gnu-nopt-2: 1h 48m -> 2h 19m (+28.7%)
  5. dist-powerpc64-linux-musl: 1h 15m -> 1h 33m (+25.1%)
  6. i686-gnu-nopt-1: 2h 27m -> 1h 50m (-24.6%)
  7. aarch64-apple: 3h 10m -> 3h 54m (+23.1%)
  8. x86_64-msvc-1: 2h 39m -> 2h 2m (-22.9%)
  9. x86_64-gnu-miri: 1h 35m -> 1h 14m (-22.8%)
  10. dist-i686-msvc: 2h 20m -> 1h 50m (-21.7%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (83b3bfc): comparison URL.

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

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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.2%, 1.7%] 6
Improvements ✅
(primary)
-0.5% [-0.7%, -0.2%] 6
Improvements ✅
(secondary)
-0.4% [-1.8%, -0.2%] 21
All ❌✅ (primary) -0.5% [-0.7%, -0.2%] 6

Max RSS (memory usage)

Results (primary 0.9%, secondary 2.8%)

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

mean range count
Regressions ❌
(primary)
0.9% [0.8%, 1.1%] 2
Regressions ❌
(secondary)
5.2% [2.2%, 10.1%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.6% [-6.9%, -2.3%] 2
All ❌✅ (primary) 0.9% [0.8%, 1.1%] 2

Cycles

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

Binary size

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

Bootstrap: 517.707s -> 516.634s (-0.21%)
Artifact size: 400.82 MiB -> 400.78 MiB (-0.01%)

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