Skip to content
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

Performance improvements for attribute value AsStringSlice, AsFloat64Slice, AsInt64Slice, AsBoolSlice #6011

Conversation

boekkooi-impossiblecloud
Copy link
Contributor

Good day,

This PR changes As[Bool|Int64|Float64|String]Slice to use a little less reflection.

The benchstat result of this is as follows.

goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/internal/attribute
cpu: AMD Ryzen 7 Pro 7735U with Radeon Graphics     
                  │   org.txt    │               new.txt                │
                  │    sec/op    │    sec/op     vs base                │
AsFloat64Slice-16   373.3n ± 41%   181.0n ± 42%  -51.51% (p=0.000 n=10)

                  │  org.txt   │              new.txt               │
                  │    B/op    │    B/op     vs base                │
AsFloat64Slice-16   64.00 ± 0%   40.00 ± 0%  -37.50% (p=0.000 n=10)

                  │  org.txt   │              new.txt               │
                  │ allocs/op  │ allocs/op   vs base                │
AsFloat64Slice-16   3.000 ± 0%   2.000 ± 0%  -33.33% (p=0.000 n=10)

Copy link

codecov bot commented Dec 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.1%. Comparing base (09105a9) to head (2c27784).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #6011     +/-   ##
=======================================
- Coverage   82.1%   82.1%   -0.1%     
=======================================
  Files        273     273             
  Lines      23652   23648      -4     
=======================================
- Hits       19437   19433      -4     
  Misses      3870    3870             
  Partials     345     345             

see 1 file with indirect coverage changes

@boekkooi-impossiblecloud boekkooi-impossiblecloud changed the title improve as slice Performance improvements for attribute value AsStringSlice, AsFloat64Slice, AsInt64Slice, AsBoolSlice Dec 1, 2024
@dmathieu dmathieu merged commit 9f82e51 into open-telemetry:main Dec 3, 2024
32 checks passed
@boekkooi-impossiblecloud boekkooi-impossiblecloud deleted the boekkooi/improve-as-slice branch December 3, 2024 21:50
@MrAlias MrAlias added this to the v1.33.0 milestone Dec 11, 2024
@MrAlias MrAlias mentioned this pull request Dec 12, 2024
MrAlias added a commit that referenced this pull request Dec 12, 2024
### Added

- Add `Reset` method to `SpanRecorder` in
`go.opentelemetry.io/otel/sdk/trace/tracetest`. (#5994)
- Add `EnabledInstrument` interface in
`go.opentelemetry.io/otel/sdk/metric/internal/x`. This is an
experimental interface that is implemented by synchronous instruments
provided by `go.opentelemetry.io/otel/sdk/metric`. Users can use it to
avoid performing computationally expensive operations when recording
measurements. It does not fall within the scope of the OpenTelemetry Go
versioning and stability [policy](./VERSIONING.md) and it may be changed
in backwards incompatible ways or removed in feature releases. (#6016)

### Changed

- The default global API now supports full auto-instrumentation from the
`go.opentelemetry.io/auto` package. See that package for more
information. (#5920)
- Propagate non-retryable error messages to client in
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#5929)
- Propagate non-retryable error messages to client in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`.
(#5929)
- Propagate non-retryable error messages to client in
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`.
(#5929)
- Performance improvements for attribute value `AsStringSlice`,
`AsFloat64Slice`, `AsInt64Slice`, `AsBoolSlice`. (#6011)
- Change `EnabledParameters` to have a `Severity` field instead of a
getter and setter in `go.opentelemetry.io/otel/log`. (#6009)

### Fixed

- Fix inconsistent request body closing in
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#5954)
- Fix inconsistent request body closing in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`.
(#5954)
- Fix inconsistent request body closing in
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`.
(#5954)
- Fix invalid exemplar keys in
`go.opentelemetry.io/otel/exporters/prometheus`. (#5995)
- Fix attribute value truncation in
`go.opentelemetry.io/otel/sdk/trace`. (#5997)
- Fix attribute value truncation in `go.opentelemetry.io/otel/sdk/log`.
(#6032)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants