perf: [durable_buffer] Avoid unnecessary copy of OTLP bytes in OtlpBytesAdapter::new()#2726
Open
gscalderon wants to merge 4 commits intoopen-telemetry:mainfrom
Open
Conversation
Replace BinaryArray::from_vec() which deep-copies the entire OTLP payload with a zero-copy construction using Buffer::from(bytes::Bytes). The clone_bytes() call is just an Arc refcount bump, and Buffer::from(Bytes) wraps the data without copying, eliminating a full memcpy on the ingest hot path. Fixes open-telemetry#2703 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
338905e to
7169a58
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2726 +/- ##
=======================================
Coverage 87.87% 87.87%
=======================================
Files 638 638
Lines 244608 244641 +33
=======================================
+ Hits 214942 214972 +30
- Misses 29142 29145 +3
Partials 524 524
🚀 New features to boost your workflow:
|
AaronRM
approved these changes
Apr 21, 2026
Contributor
AaronRM
left a comment
There was a problem hiding this comment.
Looks good to me. Thanks @gscalderon !
jmacd
approved these changes
Apr 22, 2026
utpilla
reviewed
Apr 22, 2026
utpilla
approved these changes
Apr 22, 2026
Contributor
utpilla
left a comment
There was a problem hiding this comment.
Welcome and thanks for the first PR! 🎉
Use higher-level BinaryArray::new(offsets, data_buffer, None) instead of ArrayData::builder, reducing boilerplate while preserving zero-copy behavior.
auto-merge was automatically disabled
April 22, 2026 22:54
Head branch was pushed to by a user without write access
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace
BinaryArray::from_vec()which deep-copies the entire OTLP payload with a zero-copy construction usingBuffer::from(bytes::Bytes). Theclone_bytes()call is just an Arc refcount bump, andBuffer::from(Bytes)wraps the data without copying, eliminating a full memcpy on the ingest hot path.Change Summary
Buffer::from(bytes::Bytes)instead ofBinaryArray::from_vec()to avoid deep-copying the OTLP payload into Arrow.i32::try_fromguard on payload length for a clear error on oversized payloads.test_otlp_bytes_adapter_zero_copy(pointer equality assertion) andtest_otlp_bytes_adapter_empty_payload.What issue does this PR close?
OtlpBytesAdapter::new()#2703How are these changes tested?
test_otlp_bytes_adapter,test_extract_otlp_bytes) verify correctness is preserved.test_otlp_bytes_adapter_zero_copyasserts the Arrow buffer points to the same memory as the originalOtlpProtoBytes(no copy).test_otlp_bytes_adapter_empty_payloadverifies empty payload handling.Are there any user-facing changes?
No. This is a transparent performance improvement with no API or behavior changes.