alphadose / haxmap

Fastest and most memory efficient golang concurrent hashmap
MIT License
890 stars 45 forks source link

improve haxmap performance #48

Open someview opened 2 weeks ago

someview commented 2 weeks ago

I test some different map use cases. in every case(read 100%、99%、90%、75%、 50%) test code xsync.mapof > concurrent-map(shard rwlock) > haxmap the ConcurrentMap shard map with rwlock:

//goos: windows
//goarch: amd64
//pkg: benchmap
//cpu: 12th Gen Intel(R) Core(TM) i9-12900K
//BenchmarkConcurrentMap_WarmUp
//BenchmarkConcurrentMap_WarmUp/reads=100%
//BenchmarkConcurrentMap_WarmUp/reads=100%-24           19311262            59.97 ns/op   16674108 ops/s
//BenchmarkConcurrentMap_WarmUp/reads=99%
//BenchmarkConcurrentMap_WarmUp/reads=99%-24            19390272            57.46 ns/op   17403041 ops/s
//BenchmarkConcurrentMap_WarmUp/reads=90%
//BenchmarkConcurrentMap_WarmUp/reads=90%-24            20722754            58.18 ns/op   17188562 ops/s
//BenchmarkConcurrentMap_WarmUp/reads=75%
//BenchmarkConcurrentMap_WarmUp/reads=75%-24            19096568            61.73 ns/op   16198394 ops/s
//BenchmarkConcurrentMap_WarmUp/reads=50%
//BenchmarkConcurrentMap_WarmUp/reads=50%-24            15739459            69.01 ns/op   14491307 ops/s

the xsync map result:

// goos: windows
// goarch: amd64
// pkg: benchmap
// cpu: 12th Gen Intel(R) Core(TM) i9-12900K
// BenchmarkXSyncMap_WarmUp
// BenchmarkXSyncMap_WarmUp/reads=100%
// BenchmarkXSyncMap_WarmUp/reads=100%-24           24926673            47.70 ns/op   20964357 ops/s
// BenchmarkXSyncMap_WarmUp/reads=99%
// BenchmarkXSyncMap_WarmUp/reads=99%-24            24938018            47.36 ns/op   21114211 ops/s
// BenchmarkXSyncMap_WarmUp/reads=90%
// BenchmarkXSyncMap_WarmUp/reads=90%-24            24128313            46.64 ns/op   21440622 ops/s
// BenchmarkXSyncMap_WarmUp/reads=75%
// BenchmarkXSyncMap_WarmUp/reads=75%-24            23475463            54.89 ns/op   18219448 ops/s
// BenchmarkXSyncMap_WarmUp/reads=50%
// BenchmarkXSyncMap_WarmUp/reads=50%-24            20382096            58.53 ns/op   17084646 ops/s
// PASS

the haxmap result:

//goos: windows
//goarch: amd64
//pkg: benchmap
//cpu: 12th Gen Intel(R) Core(TM) i9-12900K
//BenchmarkHaxLockFreeMap_WarmUp
//BenchmarkHaxLockFreeMap_WarmUp/reads=100%
//BenchmarkHaxLockFreeMap_WarmUp/reads=100%-24          17538038            63.97 ns/op   15631949 ops/s
//BenchmarkHaxLockFreeMap_WarmUp/reads=99%
//BenchmarkHaxLockFreeMap_WarmUp/reads=99%-24           17473504            63.95 ns/op   15638035 ops/s
//BenchmarkHaxLockFreeMap_WarmUp/reads=90%
//BenchmarkHaxLockFreeMap_WarmUp/reads=90%-24           16729821            66.61 ns/op   15012730 ops/s
//BenchmarkHaxLockFreeMap_WarmUp/reads=75%
//BenchmarkHaxLockFreeMap_WarmUp/reads=75%-24           17592495            69.28 ns/op   14433428 ops/s
//BenchmarkHaxLockFreeMap_WarmUp/reads=50%
//BenchmarkHaxLockFreeMap_WarmUp/reads=50%-24           15320367            78.30 ns/op   12770672 ops/s
//PASS

It's amazing. Maybe there cound be more performance for the lockfree map.

alphadose commented 2 weeks ago

It's amazing. Maybe there cound be more performance for the lockfree map.

there is an open issue to use xxh3 hashing instead of xxhash which might improve performance https://github.com/alphadose/haxmap/issues/41

I will look into it and publish the benchmarks for xxh3 vs xxhash for HaxMap sometime next week probably