Skip to content

cache-align the shards to improve throughput#303

Merged
xacrimon merged 4 commits into
xacrimon:masterfrom
conradludgate:cache-padding
Jun 17, 2024
Merged

cache-align the shards to improve throughput#303
xacrimon merged 4 commits into
xacrimon:masterfrom
conradludgate:cache-padding

Conversation

@conradludgate

@conradludgate conradludgate commented Jun 10, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Owner

Thanks a lot!, will merge.

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