Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduces allocation in attributes (open-telemetry#5549)
Remove one allocation in all SliceValue function (going from 3 to 2). Here is benchstat results ``` goos: linux goarch: amd64 pkg: go.opentelemetry.io/otel/internal/attribute cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ BoolSliceValue-8 128.4n ± 22% 103.8n ± 25% -19.12% (p=0.007 n=10) Int64SliceValue-8 167.9n ± 7% 130.8n ± 5% -22.13% (p=0.000 n=10) Float64SliceValue-8 133.8n ± 14% 122.6n ± 4% -8.33% (p=0.000 n=10) StringSliceValue-8 166.4n ± 9% 158.5n ± 10% -4.75% (p=0.037 n=10) geomean 148.0n 127.5n -13.88% │ old.txt │ new.txt │ │ B/op │ B/op vs base │ BoolSliceValue-8 32.000 ± 0% 8.000 ± 0% -75.00% (p=0.000 n=10) Int64SliceValue-8 88.00 ± 0% 64.00 ± 0% -27.27% (p=0.000 n=10) Float64SliceValue-8 88.00 ± 0% 64.00 ± 0% -27.27% (p=0.000 n=10) StringSliceValue-8 152.0 ± 0% 128.0 ± 0% -15.79% (p=0.000 n=10) geomean 78.34 45.25 -42.23% │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ BoolSliceValue-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10) Int64SliceValue-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10) Float64SliceValue-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10) StringSliceValue-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10) geomean 3.000 2.000 -33.33% ```
- Loading branch information