Skip to content

Reserve more capacity for Symbol interner - #164150

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
panstromek:pre-alloc-symbol-intern
Oct 12, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
panstromek:pre-alloc-symbol-intern

Conversation

@panstromek

@panstromek panstromek commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

This avoids some resizing and rehashing. More details in the added comment.

@rustbot rustbot added 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 Oct 11, 2026
@panstromek

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 Oct 11, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 11, 2026
Reserve more capacity for Symbol interner
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 5b8e645 (5b8e6453227a23b2f2e8914c1fa5ae8e7605e0d2)
Base parent: 7211ea5 (7211ea594cbf137ef6118b1752b959dea7cb9088)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown

Finished benchmarking commit (5b8e645): 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 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
Regressions ❌
(secondary)
0.8% [0.6%, 1.0%] 2
Improvements ✅
(primary)
-0.4% [-0.4%, -0.4%] 1
Improvements ✅
(secondary)
-0.8% [-4.4%, -0.1%] 49
All ❌✅ (primary) -0.4% [-0.4%, -0.4%] 1

Max RSS (memory usage)

Results (primary 1.4%, 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.4% [1.4%, 1.4%] 1
Regressions ❌
(secondary)
5.2% [1.3%, 6.7%] 7
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.2% [-8.8%, -2.2%] 11
All ❌✅ (primary) 1.4% [1.4%, 1.4%] 1

Cycles

Results (primary -2.5%, secondary 0.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)
6.3% [5.6%, 7.0%] 2
Improvements ✅
(primary)
-2.5% [-2.5%, -2.5%] 1
Improvements ✅
(secondary)
-3.0% [-3.5%, -2.4%] 3
All ❌✅ (primary) -2.5% [-2.5%, -2.5%] 1

Binary size

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

Bootstrap: 492.622s -> 489.363s (-0.66%)
Artifact size: 407.21 MiB -> 406.56 MiB (-0.16%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 11, 2026
@panstromek
panstromek force-pushed the pre-alloc-symbol-intern branch from 06db82d to bd198f3 Compare October 11, 2026 12:46
@panstromek

panstromek commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Looks good. I didn't expect include-blob to improve that much, it looks like it had to be spending quite a bit of time rehashing those blobs when resizing. Most of the improvements comes from reserve_rehash, so this looks legit. I spot-checked a few benchmarks and they follow similar pattern.

Nevertheless, my main hope for this is that it at least slightly reduces noise from some of these small benchmarks, but we will have to see how it plays out in the future.

r? nnethercote

@panstromek
panstromek marked this pull request as ready for review October 11, 2026 12:53
@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 Oct 11, 2026
@panstromek panstromek mentioned this pull request Oct 11, 2026
// reduce resizing for normal code without regresing memory use for smaller crates.
// FIXME(panstromek): we could do better if we take into account whether this is
// Debug/Opt build. Those builds intern at least 6k more symbols than Check ones.
let additional_capacity = 2400;

@nnethercote nnethercote Oct 12, 2026 •

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.

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'll leave it as let if you don't mind, I think it will make sense to make it dynamic in the future (as hinted in the fixme).

@nnethercote

Copy link
Copy Markdown
Contributor

If non-toy benchmarks use ~5,000, would that be a better value to use? Or maybe 4096?

@nnethercote

Copy link
Copy Markdown
Contributor

Anyway, seems fine, I'll let you decide the right number to use. r=me once you've decided.

@bors delegate=panstromek

@rust-bors

rust-bors Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

✌️ @panstromek, you can now approve this pull request!

If @nnethercote told you to "r=me" after making some further change, then please make that change and post @bors r=nnethercote.

View changes since this delegation.

@panstromek

Copy link
Copy Markdown
Contributor Author

Thanks!

If non-toy benchmarks use ~5,000, would that be a better value to use? Or maybe 4096?

Possibly. I wanted to get in some non-controversial number first, to serve as a baseline, before trying some more complicated tradeoff. 5k is for ucd, which is already somewhat big crate, and I wanted to make sure we don't regress some smaller real world crates we don't have in our benchmark suite (maybe some build scripts as well).

@bors r=nnethercote

Also, the regression in coercions is something unrelated based on the cachegrind diff, so I think that's just noise.

@rustbot label: +perf-regression-triaged

@rust-bors

rust-bors Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

📌 Commit bd198f3 has been approved by nnethercote

It is now in the queue for this repository.

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Oct 12, 2026
@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 Oct 12, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors rollup=iffy
Adding this to a rollup of perf-sensitive PRs

rust-bors Bot pushed a commit that referenced this pull request Oct 12, 2026
…uwer

Rollup of 4 perf-sensitive pull requests

Successful merges:

 - #163425 (Treat union fields as aliasing each other in value_analysis)
 - #164074 (Avoid cloning impl trait AST nodes in late resolution)
 - #164089 (Implement `clone_from` for `BorrowckDomain`)
 - #164150 (Reserve more capacity for Symbol interner)
@rust-bors
rust-bors Bot merged commit 4dbaa9d into rust-lang:main Oct 12, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 12, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 12, 2026
Rollup merge of #164150 - panstromek:pre-alloc-symbol-intern, r=nnethercote

Reserve more capacity for Symbol interner

This avoids some resizing and rehashing. More details in the added comment.
@rust-timer

Copy link
Copy Markdown

Note

This PR was benchmarked as part of triage of its containing rollup: triage URL.

Finished benchmarking commit (19d761c): 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.9% [0.7%, 1.1%] 2
Improvements ✅
(primary)
-0.4% [-0.7%, -0.2%] 10
Improvements ✅
(secondary)
-0.7% [-4.4%, -0.1%] 90
All ❌✅ (primary) -0.4% [-0.7%, -0.2%] 10

Max RSS (memory usage)

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

Cycles

Results (secondary 0.3%)

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

Binary size

Results (primary 0.1%, secondary 0.1%)

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

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.2%] 79
Regressions ❌
(secondary)
0.1% [0.0%, 0.2%] 47
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.0%, 0.2%] 79

Artifact size: 406.63 MiB -> 406.93 MiB (0.07%)

@panstromek

Copy link
Copy Markdown
Contributor Author

part of the result looks like the get_module_children noise again (see here).

include-blob result is the most distinct real result.

weirdsmiley pushed a commit to weirdsmiley/rust-analyzer that referenced this pull request Nov 9, 2026
…uwer

Rollup of 4 perf-sensitive pull requests

Successful merges:

 - rust-lang/rust#163425 (Treat union fields as aliasing each other in value_analysis)
 - rust-lang/rust#164074 (Avoid cloning impl trait AST nodes in late resolution)
 - rust-lang/rust#164089 (Implement `clone_from` for `BorrowckDomain`)
 - rust-lang/rust#164150 (Reserve more capacity for Symbol interner)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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.

6 participants