Skip to content

Commit 9159df6

Browse files
committed
update benchmark results
1 parent 59e00f4 commit 9159df6

File tree

3 files changed

+30
-25
lines changed

3 files changed

+30
-25
lines changed

README.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ A Golang lock-free thread-safe HashMap optimized for fastest read access.
1111

1212
It is not a general-use HashMap and currently has slow write performance for write heavy uses.
1313

14-
The minimal supported Golang version is 1.19 as it makes use of Generics and the new atomic package helpers.
15-
1614
## Usage
1715

1816
Example uint8 key map uses:
@@ -44,34 +42,34 @@ count := atomic.LoadInt64(counter) // read counter
4442
## Benchmarks
4543

4644
Reading from the hash map for numeric key types in a thread-safe way is faster than reading from a standard Golang map
47-
in an unsafe way and four times faster than Golang's `sync.Map`:
45+
in an unsafe way and three times faster than Golang's `sync.Map`:
4846

4947
```
50-
ReadHashMapUint-8 676ns ± 0%
51-
ReadHaxMapUint-8 689ns ± 1%
52-
ReadGoMapUintUnsafe-8 792ns ± 0%
53-
ReadXsyncMapUint-8 954ns ± 0%
54-
ReadGoSyncMapUint-8 2.62µs ± 1%
55-
ReadSkipMapUint-8 3.27µs ±10%
56-
ReadGoMapUintMutex-8 29.6µs ± 2%
48+
ReadXsyncMapUint-8 924.5n ± ∞ ¹
49+
ReadHashMapUint-8 1.072µ ± ∞ ¹
50+
ReadHaxMapUint-8 1.296µ ± ∞ ¹
51+
ReadGoMapUintUnsafe-8 1.318µ ± ∞ ¹
52+
ReadGoSyncMapUint-8 3.389µ ± ∞ ¹
53+
ReadSkipMapUint-8 4.820µ ± ∞ ¹
54+
ReadGoMapUintMutex-8 32.62µ ± ∞ ¹
5755
```
5856

5957
Reading from the map while writes are happening:
6058
```
61-
ReadHashMapWithWritesUint-8 860ns ± 1%
62-
ReadHaxMapWithWritesUint-8 930ns ± 1%
63-
ReadGoSyncMapWithWritesUint-8 3.06µs ± 2%
59+
ReadHashMapWithWritesUint-8 1.235µ ± ∞ ¹
60+
ReadHaxMapWithWritesUint-8 1.433µ ± ∞ ¹
61+
ReadGoSyncMapWithWritesUint-8 4.503µ ± ∞ ¹
6462
```
6563

6664
Write performance without any concurrent reads:
6765

6866
```
69-
WriteGoMapMutexUint-8 14.8µs ± 2%
70-
WriteHashMapUint-8 22.3µs ± 1%
71-
WriteGoSyncMapUint-8 69.3µs ± 0%
67+
WriteGoMapMutexUint-8 21.72µ ± ∞ ¹
68+
WriteHashMapUint-8 27.99µ ± ∞ ¹
69+
WriteGoSyncMapUint-8 78.43µ ± ∞ ¹
7270
```
7371

74-
The benchmarks were run with Golang 1.19.1 on Linux and a Ryzen 9 5900X CPU using `make benchmark-perflock`.
72+
The benchmarks were run with Golang 1.24.4 on Linux and a Ryzen 9 5900X CPU using `make benchmark-perflock`.
7573

7674
## Technical details
7775

benchmarks/go.mod

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
module github.com/cornelk/hashmap/benchmarks
22

3-
go 1.19
3+
go 1.22
4+
5+
toolchain go1.24.4
46

57
replace github.com/cornelk/hashmap => ../
68

79
require (
8-
github.com/alphadose/haxmap v1.1.0
10+
github.com/alphadose/haxmap v1.4.1
911
github.com/cornelk/hashmap v1.0.8
10-
github.com/puzpuzpuz/xsync/v2 v2.3.1
12+
github.com/puzpuzpuz/xsync/v2 v2.5.1
1113
github.com/zhangyunhao116/skipmap v0.10.1
1214
)
1315

14-
require github.com/zhangyunhao116/fastrand v0.3.0 // indirect
16+
require (
17+
github.com/zhangyunhao116/fastrand v0.3.0 // indirect
18+
golang.org/x/exp v0.0.0-20221031165847-c99f073a8326 // indirect
19+
)

benchmarks/go.sum

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
github.com/alphadose/haxmap v1.1.0 h1:M7Dxdr+civMQkWCgDpoktNpLofDBz7XzdS3rF3Y6r4U=
2-
github.com/alphadose/haxmap v1.1.0/go.mod h1:Pq2IXbl9/ytYHfrIAd7rIVtZQ2ezdIhZfvdqOizDeWY=
3-
github.com/puzpuzpuz/xsync/v2 v2.3.1 h1:oAm/nI4ZC+FqOM7t2fnA7DaQVsuj4fO2KcTcNTS1Q9Y=
4-
github.com/puzpuzpuz/xsync/v2 v2.3.1/go.mod h1:gD2H2krq/w52MfPLE+Uy64TzJDVY7lP2znR9qmR35kU=
1+
github.com/alphadose/haxmap v1.4.1 h1:VtD6VCxUkjNIfJk/aWdYFfOzrRddDFjmvmRmILg7x8Q=
2+
github.com/alphadose/haxmap v1.4.1/go.mod h1:rjHw1IAqbxm0S3U5tD16GoKsiAd8FWx5BJ2IYqXwgmM=
3+
github.com/puzpuzpuz/xsync/v2 v2.5.1 h1:mVGYAvzDSu52+zaGyNjC+24Xw2bQi3kTr4QJ6N9pIIU=
4+
github.com/puzpuzpuz/xsync/v2 v2.5.1/go.mod h1:gD2H2krq/w52MfPLE+Uy64TzJDVY7lP2znR9qmR35kU=
55
github.com/zhangyunhao116/fastrand v0.3.0 h1:7bwe124xcckPulX6fxtr2lFdO2KQqaefdtbk+mqO/Ig=
66
github.com/zhangyunhao116/fastrand v0.3.0/go.mod h1:0v5KgHho0VE6HU192HnY15de/oDS8UrbBChIFjIhBtc=
77
github.com/zhangyunhao116/skipmap v0.10.1 h1:CMH4yGZQESBM1kUNozQqQ+Ra2pKqwF3HxaTADOaIfPs=
88
github.com/zhangyunhao116/skipmap v0.10.1/go.mod h1:CClnLPHl3DI+hHgrcy0OZ/QJ45AWgA3ObVcQyJop12c=
9+
golang.org/x/exp v0.0.0-20221031165847-c99f073a8326 h1:QfTh0HpN6hlw6D3vu8DAwC8pBIwikq0AI1evdm+FksE=
10+
golang.org/x/exp v0.0.0-20221031165847-c99f073a8326/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=

0 commit comments

Comments
 (0)