-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[pkg/pdatautil] Optimize the hashing function for pcommon.Map
#27840
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6f4d29a
to
00b0a85
Compare
dmitryax
approved these changes
Oct 19, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the contribution, @mdonkers!
pcommon.Map
pcommon.Map
martin-majlis-s1
pushed a commit
to scalyr/opentelemetry-collector-contrib
that referenced
this pull request
Oct 20, 2023
…-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.
sigilioso
pushed a commit
to carlossscastro/opentelemetry-collector-contrib
that referenced
this pull request
Oct 27, 2023
…-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.
jmsnll
pushed a commit
to jmsnll/opentelemetry-collector-contrib
that referenced
this pull request
Nov 12, 2023
…-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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Improve the performance of the
MapHash
function, mostly by using the xxhash architecture optimized version.hash.Sum
is a 'Go-code' only implementationxxhash.Sum64
has optimized versions for different architecturesBoth result in the exact same hash though.
For the given benchmarks, the gain is > 10%
From
main
:The PR:
Testing:
(Re-)using the same tests and benchmarks to prove semantics didn't change.
Documentation:
none