Commit fdb01e3
perf: [durable_buffer] Avoid unnecessary copy of OTLP bytes in OtlpBytesAdapter::new() (open-telemetry#2726)
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.
# Change Summary
- **Zero-copy wrapping**: Use `Buffer::from(bytes::Bytes)` instead of
`BinaryArray::from_vec()` to avoid deep-copying the OTLP payload into
Arrow.
- **Bounds check**: Added explicit `i32::try_from` guard on payload
length for a clear error on oversized payloads.
- **New tests**: `test_otlp_bytes_adapter_zero_copy` (pointer equality
assertion) and `test_otlp_bytes_adapter_empty_payload`.
## What issue does this PR close?
* Closes open-telemetry#2703
## How are these changes tested?
- Existing tests (`test_otlp_bytes_adapter`, `test_extract_otlp_bytes`)
verify correctness is preserved.
- New `test_otlp_bytes_adapter_zero_copy` asserts the Arrow buffer
points to the same memory as the original `OtlpProtoBytes` (no copy).
- New `test_otlp_bytes_adapter_empty_payload` verifies empty payload
handling.
## Are there any user-facing changes?
No. This is a transparent performance improvement with no API or
behavior changes.
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 8f6fa92 commit fdb01e3
1 file changed
Lines changed: 52 additions & 2 deletions
File tree
- rust/otap-dataflow/crates/core-nodes/src/processors/durable_buffer_processor
Lines changed: 52 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
348 | 349 | | |
349 | 350 | | |
350 | 351 | | |
351 | | - | |
352 | | - | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
353 | 368 | | |
354 | 369 | | |
355 | 370 | | |
| |||
736 | 751 | | |
737 | 752 | | |
738 | 753 | | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
739 | 789 | | |
740 | 790 | | |
741 | 791 | | |
| |||
0 commit comments