feat(trace-utils)!: change buffer implementation#2055
Conversation
Add the main ChangeBufferState<T> struct and its full implementation: span creation/pooling, change buffer interpretation (opcodes), deferred tag resolution, span header materialization, flush logic, and string table management. This is the core state machine that processes batched span mutations from JS/WASM via a shared memory buffer. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📚 Documentation Check Results📦
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f874ddf2f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let num: u32 = self.change_buffer.read_unchecked(index); | ||
| self.string_table | ||
| .get_unchecked(num as usize) | ||
| .clone() | ||
| .unwrap_unchecked() |
There was a problem hiding this comment.
Keep FFI buffer decoding checked
When a cached non-create operation such as SetName or SetServiceName is decoded from the shared FFI buffer, the caller reaches this helper without validating either that the string id is still present in string_table or that the argument bytes are in bounds. An out-of-sync/evicted string id that used to produce ChangeBufferError::StringNotFound now hits unwrap_unchecked(), which is undefined behavior across the FFI-facing change-buffer path rather than a recoverable error.
Useful? React with 👍 / 👎.
Clippy Allow Annotation ReportComparing clippy allow annotations between branches:
Summary by Rule
Annotation Counts by File
Annotation Stats by Crate
About This ReportThis report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality. |
🔒 Cargo Deny Results📦
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## yannham/change-buffer-foundation #2055 +/- ##
====================================================================
- Coverage 73.03% 72.47% -0.56%
====================================================================
Files 465 465
Lines 76881 77436 +555
====================================================================
- Hits 56147 56122 -25
- Misses 20734 21314 +580
🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
What does this PR do?
This PR backports the change buffer implementation required for dd-trace-js adoption of native spans. Follow-up of #2046.
The change buffer is a contiguous region of memory where span operations are encoded from the JS runtime, similar to a byte code. The implementation decode all those span events and reconstruct the corresponding span objects.
Motivation
Required to land native spans dd-trace-js.
How to test the change?
tests included.