Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test out a more lock-free hash map #138419

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Mar 12, 2025

This tests out the more lock-free hash map from my horde crate by using it as the default query map. The integration with DynSync / DynSend in this PR is unsound.

Shards are no longer used for the map, which means all writes are behind a single lock. Reads are lock-free.

@rustbot
Copy link
Collaborator

rustbot commented Mar 12, 2025

r? @Nadrieril

rustbot has assigned @Nadrieril.
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

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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 Mar 12, 2025
@rust-log-analyzer

This comment has been minimized.

@lqd
Copy link
Member

lqd commented Mar 12, 2025

@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 Mar 12, 2025
@bors
Copy link
Contributor

bors commented Mar 12, 2025

⌛ Trying commit 2947bae with merge b73204a...

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 12, 2025
Test out a more lock-free hash map

This tests out the more lock-free hash map from my [horde](https://crates.io/crates/horde) crate by using it as the default query map. The integration with `DynSync` / `DynSend` in this PR is unsound.

Shards are no longer used for the map, which means all writes are behind a single lock. Reads are lock-free.
@bors
Copy link
Contributor

bors commented Mar 12, 2025

☔ The latest upstream changes (presumably #138414) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Contributor

bors commented Mar 12, 2025

☀️ Try build successful - checks-actions
Build commit: b73204a (b73204a7a915c62fc1367f8bdf8f3ff971d2e4c6)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b73204a): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
0.2% [0.2%, 0.3%] 2
Regressions ❌
(secondary)
1.8% [1.8%, 1.9%] 6
Improvements ✅
(primary)
-0.4% [-1.3%, -0.1%] 35
Improvements ✅
(secondary)
-0.9% [-1.6%, -0.2%] 35
All ❌✅ (primary) -0.4% [-1.3%, 0.3%] 37

Max RSS (memory usage)

Results (secondary 5.1%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
6.7% [3.0%, 8.0%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.3% [-1.3%, -1.3%] 1
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 779.458s -> 783.14s (0.47%)
Artifact size: 365.27 MiB -> 362.93 MiB (-0.64%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 13, 2025
@Zoxc
Copy link
Contributor Author

Zoxc commented Mar 13, 2025

Local test with 8 threads / 8 cores:

BenchmarkBeforeAfterBeforeAfterBeforeAfter
TimeTime%Physical MemoryPhysical Memory%Committed MemoryCommitted Memory%
🟣 clap:check0.4593s0.4569s -0.52%203.55 MiB202.20 MiB -0.67%270.26 MiB268.65 MiB -0.60%
🟣 hyper:check0.1369s0.1360s -0.61%128.02 MiB127.29 MiB -0.57%192.46 MiB191.54 MiB -0.47%
🟣 regex:check0.2915s0.2898s -0.59%163.22 MiB162.03 MiB -0.73%222.23 MiB220.81 MiB -0.64%
🟣 syn:check0.5602s0.5591s -0.19%198.26 MiB197.50 MiB -0.38%258.15 MiB257.16 MiB -0.38%
Total1.4478s1.4418s -0.42%693.05 MiB689.01 MiB -0.58%943.09 MiB938.16 MiB -0.52%
Summary1.0000s0.9952s -0.48%1 byte0.99 bytes -0.59%1 byte0.99 bytes -0.52%

Local test with 16 threads / 8 cores:

BenchmarkBeforeAfterBeforeAfterBeforeAfter
TimeTime%Physical MemoryPhysical Memory%Committed MemoryCommitted Memory%
🟣 clap:check0.4308s0.4243s💚 -1.51%210.82 MiB209.18 MiB -0.78%278.63 MiB276.88 MiB -0.63%
🟣 hyper:check0.1350s0.1336s💚 -1.03%131.61 MiB130.79 MiB -0.63%196.52 MiB195.54 MiB -0.50%
🟣 regex:check0.2834s0.2795s💚 -1.37%168.81 MiB167.36 MiB -0.86%228.35 MiB226.61 MiB -0.76%
🟣 syn:check0.5418s0.5379s -0.71%204.90 MiB204.09 MiB -0.39%264.86 MiB263.87 MiB -0.38%
Total1.3910s1.3754s💚 -1.13%716.14 MiB711.42 MiB -0.66%968.35 MiB962.89 MiB -0.56%
Summary1.0000s0.9884s💚 -1.16%1 byte0.99 bytes -0.66%1 byte0.99 bytes -0.57%

It does seem to reduce congestion even with the single write lock.

@Zoxc
Copy link
Contributor Author

Zoxc commented Mar 14, 2025

I added a commit that uses this for type interning also.

Local test with 16 threads / 8 cores for just the type interning change:

BenchmarkBeforeAfterBeforeAfterBeforeAfter
TimeTime%Physical MemoryPhysical Memory%Committed MemoryCommitted Memory%
🟣 clap:check0.4460s0.4432s -0.62%208.13 MiB165.73 MiB💚 -20.37%276.49 MiB215.77 MiB💚 -21.96%
🟣 hyper:check0.1399s0.1293s💚 -7.53%129.73 MiB89.35 MiB💚 -31.12%195.33 MiB131.10 MiB💚 -32.89%
🟣 regex:check0.2890s0.2789s💚 -3.47%166.27 MiB122.74 MiB💚 -26.18%226.41 MiB163.21 MiB💚 -27.92%
🟣 syn:check0.5584s0.5499s💚 -1.53%203.10 MiB159.39 MiB💚 -21.53%263.71 MiB200.96 MiB💚 -23.79%
Total1.4333s1.4014s💚 -2.22%707.23 MiB537.21 MiB💚 -24.04%961.94 MiB711.03 MiB💚 -26.08%
Summary1.0000s0.9671s💚 -3.29%1 byte0.75 bytes💚 -24.80%1 byte0.73 bytes💚 -26.64%

It does seem like sharding wasted quite a bit of memory.

@lqd
Copy link
Member

lqd commented Mar 14, 2025

We can do another perf run if you’d like, but the conflicts would need to be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) perf-regression Performance regression. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants