Skip to content

Performance improvement

Compare
Choose a tag to compare
@alphadose alphadose released this 31 Aug 21:48
· 51 commits to main since this release

Notes

  • Improve hashing performance by switching to pure arithmetic and bitmasking for known key sizes

Benchmarks

Benchmarks were performed against golang sync.Map and the latest cornelk-hashmap

All results were computed from benchstat of 20 runs

  1. Concurrent Reads Only
name                         time/op
HaxMapReadsOnly-8            7.13µs ± 5%
GoSyncMapReadsOnly-8         22.4µs ± 2%
CornelkMapReadsOnly-8        8.28µs ± 1%
  1. Concurrent Reads with Writes
name                         time/op
HaxMapReadsWithWrites-8      8.44µs ± 5%
GoSyncMapReadsWithWrites-8   26.1µs ± 2%
CornelkMapReadsWithWrites-8  9.55µs ± 2%

name                         alloc/op
HaxMapReadsWithWrites-8      1.22kB ± 6%
GoSyncMapReadsWithWrites-8   6.06kB ± 6%
CornelkMapReadsWithWrites-8  1.56kB ± 5%

name                         allocs/op
HaxMapReadsWithWrites-8         152 ± 6%
GoSyncMapReadsWithWrites-8      562 ± 6%
CornelkMapReadsWithWrites-8     195 ± 5%