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

Update KeyValue to avoid copying non-static string slices #2089

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

utpilla
Copy link
Contributor

@utpilla utpilla commented Sep 10, 2024

Related to #1642

Changes

  • Update Value struct to avoid copying non-static string slices

Benchmarks

  • There is around a 32% improvement in perf for the scenario where the attribute values are not static string slices
  • No regression with other existing scenarios 

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@utpilla utpilla requested a review from a team September 10, 2024 00:00
@utpilla utpilla marked this pull request as draft September 10, 2024 00:00
@@ -10,7 +10,7 @@ RAM: 64.0 GB
| CreateTupleKeyValue | 671 ps |
| CreateOtelKeyValueArray | 18.4 ns |
| CreateOtelKeyValueArrayWithMixedValueTypes | 18.1 ns |
| CreateOtelKeyValueArrayWithNonStaticValues | 90.1 ns |
| CreateOtelKeyValueArrayWithNonStaticValues | 61.2 ns |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cijothomas The changes in this PR are helpful for this scenario.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add metric e2e benchmarks too? the counter.add and friends

Copy link

codecov bot commented Sep 10, 2024

Codecov Report

Attention: Patch coverage is 64.20455% with 63 lines in your changes missing coverage. Please review.

Project coverage is 77.9%. Comparing base (66f29b8) to head (91f0a1d).

Files with missing lines Patch % Lines
opentelemetry/src/common.rs 68.5% 11 Missing ⚠️
opentelemetry-proto/src/transform/common.rs 11.1% 8 Missing ⚠️
opentelemetry/src/baggage.rs 63.6% 8 Missing ⚠️
opentelemetry-stdout/src/common.rs 0.0% 7 Missing ⚠️
opentelemetry/src/metrics/noop.rs 0.0% 6 Missing ⚠️
opentelemetry/src/trace/noop.rs 0.0% 4 Missing ⚠️
opentelemetry-proto/src/transform/metrics.rs 0.0% 2 Missing ⚠️
opentelemetry/src/global/trace.rs 66.6% 2 Missing ⚠️
opentelemetry/src/metrics/instruments/counter.rs 33.3% 2 Missing ⚠️
opentelemetry/src/metrics/instruments/gauge.rs 33.3% 2 Missing ⚠️
... and 9 more
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #2089   +/-   ##
=====================================
  Coverage   77.9%   77.9%           
=====================================
  Files        121     121           
  Lines      20969   20960    -9     
=====================================
+ Hits       16335   16347   +12     
+ Misses      4634    4613   -21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cijothomas
Copy link
Member

  1. Would love to add benchmarks for Metrics to see the overall gains in metric hot path.
  2. Given this is doable without disrupting users, I'd prefer to park this and get back post RC stage, so we can focus on fixing critical bugs/feature gaps now.

As usual, great work! Thanks for constantly pursuing to get the highest performance. From my knowledge of other OTel clients, none of them allow alloc-free recordings when the key/values are a slice/part of an existing string, so this is a great improvement!

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.

2 participants