-
Notifications
You must be signed in to change notification settings - Fork 50
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
now we can use xxh3 to speed up #41
Comments
@welldonexing thanks for the update, xxh3 is indeed faster and I am also planning to make a switch on another note how does your xxh3 library compare with Cyan4973/xxHash performance wise for xxh3 algo only ? |
yes ,by my simple test , it 's almost the same to old one ,but that 's almost the only one xxh3 writen in go .
the question is https://github.com/zeebo/xxh3/blob/master/hash64.go use the str type maybe faster when directly using pointer.or []byte |
nice, I will change to xxh3 hashing and publish a new release possibly this weekend PS:- I think xxh3 will give a considerable speed boost for long string key types but for int, uint, float etc there shouldn't be any difference |
xxhash3 outperforms xxhash in string hashing, according to benchmark results on my machine.
|
why don't you want to use the FNV family of algorithms? prime := 17861029589083791777
h := 14695981039346656037
for _, b := range bytes {
h ^= uint64(b)
h *= prime
}
return h And that's it |
@mvestnik can you run a benchmark test with the FNV hash algorithm similar to this one https://github.com/alphadose/haxmap/blob/main/benchmarks/map_test.go ? You can use also if possible randomize the input dataset so that there is less bias in the final benchmark results |
I wrote a simple benchmark. You can check the results: package experiment
import (
"testing"
"github.com/cespare/xxhash/v2"
)
const (
prime uint64 = 17861029589083791777
offsetBasis uint64 = 14695981039346656037
)
func fnv64(bytes []byte) uint64 {
h := offsetBasis
for _, b := range bytes {
h ^= uint64(b)
h *= prime
}
return h
}
func xxh64(bytes []byte) uint64 {
return xxhash.Sum64(bytes)
}
func BenchmarkFNV64(b *testing.B) {
for i := 0; i < b.N; i++ {
fnv64([]byte{102, 105, 120, 116, 117, 114, 101})
}
}
func BenchmarkXXH64(b *testing.B) {
for i := 0; i < b.N; i++ {
xxh64([]byte{102, 105, 120, 116, 117, 114, 101})
}
} |
I guess Also,
|
Could guys also benchmark wyhash? https://github.com/zeebo/wyhash readme says it a little faster(?) than https://github.com/zeebo/xxh3 For ref: https://bloomberg.github.io/bde/articles/wyhash.html |
https://github.com/zeebo/xxh3
// your custom hash function
func customStringHasher(s string) uintptr {
return uintptr(xxh3.HashString(s))
}
The text was updated successfully, but these errors were encountered: