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

cache-align the shards to improve throughput #303

Merged
merged 4 commits into from
Jun 17, 2024

Conversation

conradludgate
Copy link
Contributor

@conradludgate conradludgate commented Jun 10, 2024

Using CachePadded to cache-align the rwlock shards for improved locking performance. This offers considerable (30-50%) improvements in both latency and throughput perf on my M2.

Note

This increases memory usage. On x86_64, the cache alignment is set to 128. The current size of RwLock<HashMap<K, V, std::RandomState>> is 8 + 16 + 32 = 56 bytes. The current size of RwLock<HashMap<K, V, ahash::RandomState>> is 8 + 32 + 32 = 72 bytes. So this will double the size of the empty collection. Eg on a 64 core CPU the empty std dashmap size will increase from 14KiB to 32KiB. This size increase is constant though and does not scale per element inserted into the map.

Important

This is a breaking change for the raw shards api.

Benchmark results

In this benchmark,

  • DashMap is the released version 5.3.3
  • DashMap2 is this version

RapidGrow ahash latency
RapidGrow ahash throughput

Exchange ahash latency
Exchange ahash throughput

ReadHeavy ahash latency
ReadHeavy ahash throughput

RapidGrow std latency
RapidGrow std throughput

Exchange std latency
Exchange std throughput

ReadHeavy std latency
ReadHeavy std throughput

@xacrimon
Copy link
Owner

Thanks a lot!, will merge.

@xacrimon xacrimon merged commit 92d64ba into xacrimon:master Jun 17, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants