Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pkg/pdatautil] Optimize the hashing function for
pcommon.Map
(open…
…-telemetry#27840) **Description:** Improve the performance of the `MapHash` function, mostly by using the xxhash architecture optimized version. `hash.Sum` is a 'Go-code' only implementation `xxhash.Sum64` has optimized versions for different architectures Both result in the exact same hash though. For the given benchmarks, the gain is > 10% From `main`: ``` goos: linux goarch: amd64 pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil cpu: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz BenchmarkMapHashFourItems-16 47676003 236.0 ns/op 24 B/op 1 allocs/op BenchmarkMapHashEightItems-16 22551222 532.3 ns/op 32 B/op 2 allocs/op BenchmarkMapHashWithEmbeddedSliceAndMap-16 14098969 893.1 ns/op 56 B/op 3 allocs/op ``` The PR: ``` goos: linux goarch: amd64 pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil cpu: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz BenchmarkMapHashFourItems-16 59854737 203.4 ns/op 24 B/op 1 allocs/op BenchmarkMapHashEightItems-16 25609375 475.0 ns/op 32 B/op 2 allocs/op BenchmarkMapHashWithEmbeddedSliceAndMap-16 15950144 753.8 ns/op 56 B/op 3 allocs/op ``` **Testing:** (Re-)using the same tests and benchmarks to prove semantics didn't change.
- Loading branch information