Why there are two type of hash function? #1341
-
i find there are two type of hash function. what is the difference? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
I think there are some performance differences. Kindly ping @brancz. Do you happen to remember the reason? |
Beta Was this translation helpful? Give feedback.
-
I think I benchmarked them against each other in parca-agent and highwayhash performed better. But I failed to keep the results around so we should repeat the experiment and document it this time. |
Beta Was this translation helpful? Give feedback.
-
In terms of speed they are similar.
import (
// ...
highwayhash "github.com/parca-dev/parca-agent/pkg/hash"
xxhash "github.com/parca-dev/parca/pkg/hash"
)
var (
hstr string
hint uint64
)
func BenchmarkHash142mbXxhash(b *testing.B) {
name := filepath.Join("../../dist", "parca")
f, err := os.Open(name)
if err != nil {
b.Fatal(err)
}
b.Cleanup(func() {
f.Close()
})
b.ResetTimer()
for i := 0; i < b.N; i++ {
hstr, err = xxhash.Reader(f)
if err != nil {
b.Fatal(err)
}
}
}
func BenchmarkHash142mbHighwayhash(b *testing.B) {
name := filepath.Join("../../dist", "parca")
f, err := os.Open(name)
if err != nil {
b.Fatal(err)
}
b.Cleanup(func() {
f.Close()
})
b.ResetTimer()
for i := 0; i < b.N; i++ {
hint, err = highwayhash.Reader(f)
if err != nil {
b.Fatal(err)
}
}
} |
Beta Was this translation helpful? Give feedback.
-
I think it was initially for hashing the kallsyms file for resolving kernel symbols? Either way this is also awesome to have documented in this issue! |
Beta Was this translation helpful? Give feedback.
I think it was initially for hashing the kallsyms file for resolving kernel symbols? Either way this is also awesome to have documented in this issue!