Skip to content

Experiment: Replace ShardedHashMap method insert with debug-checked insert_unique#155550

Draft
zetanumbers wants to merge 2 commits intorust-lang:mainfrom
zetanumbers:cache_insert_unique
Draft

Experiment: Replace ShardedHashMap method insert with debug-checked insert_unique#155550
zetanumbers wants to merge 2 commits intorust-lang:mainfrom
zetanumbers:cache_insert_unique

Conversation

@zetanumbers
Copy link
Copy Markdown
Contributor

Currently every use of ShardedHashMap::insert checks that it won't evict an old value due to unique key. I haven't found any issue related to that faulty condition, so I thought of replacing it with ShardedHashMap::insert_unique which doesn't check for this condition unless debug_assertions are enabled. This might improve the performance.

r? @petrochenkov

@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 Apr 20, 2026
@rust-log-analyzer

This comment has been minimized.

@lqd
Copy link
Copy Markdown
Member

lqd commented Apr 20, 2026

@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 Apr 20, 2026
rust-bors bot pushed a commit that referenced this pull request Apr 20, 2026
Experiment: Replace `ShardedHashMap` method `insert` with debug-checked `insert_unique`
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 20, 2026

☀️ Try build successful (CI)
Build commit: db613ff (db613ff78761d3debfa74a42bb3a2f4d649e3a2b, parent: e22c616e4e87914135c1db261a03e0437255335e)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (db613ff): comparison URL.

Overall result: ✅ improvements - no action needed

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.

@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.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
-0.4% [-0.7%, -0.2%] 10
Improvements ✅
(secondary)
-0.5% [-0.7%, -0.1%] 23
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 -2.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
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.5%] 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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.1%, -0.0%] 20
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.0%] 19
All ❌✅ (primary) -0.1% [-0.1%, -0.0%] 20

Bootstrap: 507.073s -> 490.745s (-3.22%)
Artifact size: 394.31 MiB -> 394.24 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants