Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add xsync MapOf to benchmarks #22

Merged
merged 1 commit into from
Nov 3, 2022

Conversation

puzpuzpuz
Copy link
Contributor

Adds xsync MapOf to the benchmarks to have one more map in the comparison.

Results on my machine are the following:

$ go test -benchmem -bench .
goos: linux
goarch: amd64
pkg: github.com/alphadose/haxmap/benchmarks
cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
BenchmarkHaxMapReadsOnly-8             	  174625	      6876 ns/op	       0 B/op	       0 allocs/op
BenchmarkHaxMapReadsWithWrites-8       	  149389	      7895 ns/op	     963 B/op	     120 allocs/op
BenchmarkGoSyncMapReadsOnly-8          	   60259	     19771 ns/op	       0 B/op	       0 allocs/op
BenchmarkGoSyncMapReadsWithWrites-8    	   52824	     22527 ns/op	    4874 B/op	     452 allocs/op
BenchmarkCornelkMapReadsOnly-8         	  178738	      6657 ns/op	       0 B/op	       0 allocs/op
BenchmarkCornelkMapReadsWithWrites-8   	  150156	      8103 ns/op	    1026 B/op	     128 allocs/op
BenchmarkXsyncMapReadsOnly-8           	  294196	      3993 ns/op	       0 B/op	       0 allocs/op
BenchmarkXsyncMapReadsWithWrites-8     	  241662	      4698 ns/op	     922 B/op	      57 allocs/op
PASS
ok  	github.com/alphadose/haxmap/benchmarks	10.413s

@bagualing
Copy link

Wow, xsync is knocking on the door.
The latest update of xsync has a significant performance boost.

@puzpuzpuz
Copy link
Contributor Author

@bagualing thanks. Yeah, MapOf got more efficient in scenarios when the data set is small in the latest version.

@alphadose alphadose merged commit a1f6979 into alphadose:main Nov 3, 2022
@alphadose
Copy link
Owner

@puzpuzpuz really great work, I will definitely check out xsync map implementation in more depth

I will also see if current haxmap performance can be improved from drawing inspiration from xsync map

@puzpuzpuz puzpuzpuz deleted the update-xsync-version branch November 3, 2022 18:09
@puzpuzpuz
Copy link
Contributor Author

I will definitely check out xsync map implementation in more depth

That would be awesome. You should be looking into MapOf (generic map) as it's different from Map (non-generic map). MapOf overall design is quite simple: a hash table of cache-line-sized buckets holding key hashes + pointers to immutable key-value pairs. Each bucket is organized in a unrolled linked list and protected with a sync.Mutex. The rehashing involves a bit tricky synchronization, but still not very complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants