Repository navigation
Reorder Map bucket fields to avoid false sharing on writes - #206
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #206 +/- ##
==========================================
- Coverage 99.54% 98.85% -0.69%
==========================================
Files 7 7
Lines 875 875
==========================================
- Hits 871 865 -6
- Misses 4 9 +5
- Partials 0 1 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bucketPaddedis exactly 64 bytes (one cache line) and contains GC-relevant pointers, somake([]bucketPadded, n)is allocated via Go's small-object path. For size classes that fall into the[16, 512)bucket range, the Go allocator prefixes the allocation with an 8-byte malloc header, which makes the slice base sit at offset8 (mod 64)rather than0. Each buckettherefore occupies two cache lines.
The fix reorder the fields in
bucketso thatmuprecedesnext:Benchmarks
The existing
BenchmarkMap_WarmUp/BenchmarkMapInt_WarmUpbenchmarks useWithPresize(1000), which produces a 512-bucket table - already in the aligned range. They should show no change.