Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use encoding/binary to convert hashing seed for better performance (#…
…31660) **Description:** I was exploring this processor to better understand how it works and when reading this function it took me a minute to make sure I understood that it was converting the seed to LittleEndian ordering. I decided to see if using the provided `encoding/binary` function would show a performance improvement and it does. I believe this change improves the readability of this function as well as improves the performance (albeit likely in a marginal way for overall performance of this processor) It also doesn't seem like a changelog entry is needed here given this is a minor refactor. **Testing:** I added a benchmark to show improved performance which I ran locally with: `go test -bench="Benchmark*" -run=XXX -benchmem -benchtime=5s -count=10` Then I compared the previous version to mine using `benchstat` ``` goos: darwin goarch: arm64 pkg: github.com/open-telemetry/opentelemetry-collector-contrib/processor/probabilisticsamplerprocessor │ old_enc.out │ new_enc.out │ │ sec/op │ sec/op vs base │ 32tob-10 2.5105n ± 1% 0.3138n ± 0% -87.50% (p=0.000 n=10) │ old_enc.out │ new_enc.out │ │ B/op │ B/op vs base │ 32tob-10 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ ¹ all samples are equal │ old_enc.out │ new_enc.out │ │ allocs/op │ allocs/op vs base │ 32tob-10 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ ¹ all samples are equal ```
- Loading branch information