Skip to content

Hashing performance improvement

Compare
Choose a tag to compare
@alphadose alphadose released this 29 Aug 07:16
· 61 commits to main since this release

Notes

Performance gain obtained by inlining hash function assignments

Benchmarks

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

All results were computed from benchstat of 20 runs (code available here)

  1. Concurrent Reads Only
name                         time/op
HaxMapReadsOnly-8            9.18µs ±12%
GoSyncMapReadsOnly-8         22.5µs ± 5%
CornelkMapReadsOnly-8        10.4µs ± 4%

name                         alloc/op
HaxMapReadsOnly-8             0.00B
GoSyncMapReadsOnly-8          0.00B
CornelkMapReadsOnly-8         0.00B

name                         allocs/op
HaxMapReadsOnly-8              0.00
GoSyncMapReadsOnly-8           0.00
CornelkMapReadsOnly-8          0.00
  1. Concurrent Reads with Writes
name                         time/op
HaxMapReadsWithWrites-8      10.5µs ± 7%
GoSyncMapReadsWithWrites-8   25.6µs ± 7%
CornelkMapReadsWithWrites-8  12.3µs ± 6%

name                         alloc/op
HaxMapReadsWithWrites-8      1.28kB ± 5%
GoSyncMapReadsWithWrites-8   6.23kB ± 6%
CornelkMapReadsWithWrites-8  5.89kB ± 7%

name                         allocs/op
HaxMapReadsWithWrites-8         159 ± 5%
GoSyncMapReadsWithWrites-8      577 ± 6%
CornelkMapReadsWithWrites-8     210 ± 8%

From the above results it is evident that haxmap takes the least time, memory and allocations in all cases