-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 recordingSpan
SetAttributes
and addOverCapAttrs
#5864
Performance improvements for recordingSpan
SetAttributes
and addOverCapAttrs
#5864
Conversation
benchstat: ``` goos: linux goarch: amd64 pkg: go.opentelemetry.io/otel/sdk/trace cpu: 11th Gen Intel(R) Core(TM) i5-11400H @ 2.70GHz │ new.txt │ new1.txt │ │ sec/op │ sec/op vs base │ TraceStart/with_a_simple_span-12 451.0n ± 5% 375.0n ± 1% -16.85% (p=0.000 n=10) TraceStart/with_several_links-12 595.8n ± 3% 501.7n ± 1% -15.80% (p=0.000 n=10) TraceStart/with_attributes-12 644.5n ± 10% 569.5n ± 4% -11.63% (p=0.000 n=10) geomean 557.4n 474.9n -14.79% │ new.txt │ new1.txt │ │ B/op │ B/op vs base │ TraceStart/with_a_simple_span-12 496.0 ± 0% 496.0 ± 0% ~ (p=1.000 n=10) ¹ TraceStart/with_several_links-12 672.0 ± 0% 672.0 ± 0% ~ (p=1.000 n=10) ¹ TraceStart/with_attributes-12 752.0 ± 0% 752.0 ± 0% ~ (p=1.000 n=10) ¹ geomean 630.5 630.5 +0.00% ¹ all samples are equal │ new.txt │ new1.txt │ │ allocs/op │ allocs/op vs base │ TraceStart/with_a_simple_span-12 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹ TraceStart/with_several_links-12 3.000 ± 0% 3.000 ± 0% ~ (p=1.000 n=10) ¹ TraceStart/with_attributes-12 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=10) ¹ geomean 2.884 2.884 +0.00% ¹ all samples are equal ```
Grow increases the slice's capacity, if necessary, to guarantee space for another n elements. This change now ensures that `n` is the amount of elements to grow and not the capacity amount.
Could you post benchstat results showing the improvements? |
This comment was marked as outdated.
This comment was marked as outdated.
38f3de7
to
19940d4
Compare
19940d4
to
48156c1
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5864 +/- ##
=======================================
- Coverage 84.6% 84.5% -0.1%
=======================================
Files 272 272
Lines 22779 22800 +21
=======================================
+ Hits 19272 19283 +11
- Misses 3165 3171 +6
- Partials 342 346 +4 |
Hey @dashpole Benchstat for f6fd877 are as follows.
|
Co-authored-by: Damien Mathieu <42@dmathieu.com>
Good day, Thanks for review this PR! This PR follows from #5864 and avoid multiple locks in `End`, `RecordError`, `AddEvent` and `AddLink`. Benchstats result are: ``` goos: linux goarch: amd64 pkg: go.opentelemetry.io/otel/sdk/trace cpu: 11th Gen Intel(R) Core(TM) i5-11400H @ 2.70GHz │ event-3cbd9671.txt │ event-pr-e9744b48.txt │ │ sec/op │ │ SpanEnd-12 63.07n ± 1% 53.63n ± 1% -14.97% (p=0.000 n=10) │ event-3cbd9671.txt │ event-pr-e9744b48.txt │ │ B/op │ B/op vs base │ SpanEnd-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ ¹ all samples are equal │ event-3cbd9671.txt │ event-pr-e9744b48.txt │ │ allocs/op │ allocs/op vs base │ SpanEnd-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ ¹ all samples are equal ``` --------- Co-authored-by: David Ashpole <dashpole@google.com> Co-authored-by: Damien Mathieu <42@dmathieu.com>
### Added - Add `go.opentelemetry.io/otel/sdk/metric/exemplar` package which includes `Exemplar`, `Filter`, `TraceBasedFilter`, `AlwaysOnFilter`, `HistogramReservoir`, `FixedSizeReservoir`, `Reservoir`, `Value` and `ValueType` types. These will be used for configuring the exemplar reservoir for the metrics sdk. (#5747, #5862) - Add `WithExportBufferSize` option to log batch processor.(#5877) ### Changed - Enable exemplars by default in `go.opentelemetry.io/otel/sdk/metric`. Exemplars can be disabled by setting `OTEL_METRICS_EXEMPLAR_FILTER=always_off` (#5778) - `Logger.Enabled` in `go.opentelemetry.io/otel/log` now accepts a newly introduced `EnabledParameters` type instead of `Record`. (#5791) - `FilterProcessor.Enabled` in `go.opentelemetry.io/otel/sdk/log/internal/x` now accepts `EnabledParameters` instead of `Record`. (#5791) - The `Record` type in `go.opentelemetry.io/otel/log` is no longer comparable. (#5847) - Performance improvements for the trace SDK `SetAttributes` method in `Span`. (#5864) - Reduce memory allocations for the `Event` and `Link` lists in `Span`. (#5858) - Performance improvements for the trace SDK `AddEvent`, `AddLink`, `RecordError` and `End` methods in `Span`. (#5874) ### Deprecated - Deprecate all examples under `go.opentelemetry.io/otel/example` as they are moved to [Contrib repository](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/examples). (#5854) ### Fixed - The race condition for multiple `FixedSize` exemplar reservoirs identified in #5814 is resolved. (#5819) - Fix log records duplication in case of heterogeneous resource attributes by correctly mapping each log record to it's resource and scope. (#5803) - Fix timer channel drain to avoid hanging on Go 1.23. (#5868) - Fix delegation for global meter providers, and panic when calling otel.SetMeterProvider. (#5827) - Change the `reflect.TypeOf` to use a nil pointer to not allocate on the heap unless necessary. (#5827)
Good day,
While working on #5858 I found some other possible improvements.
This PR:
SetAttributes
when no attributes are provided.s.attributes
to guarantee that there is enough space for elements to be added.truncateAttr
was not used when a attribute was being updated inaddOverCapAttrs
.Thanks for reviewing and please let me know if any changes are needed.