feat(trace-utils)!: change buffer implementation#2055
Conversation
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. |
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:
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: acc2888 | Docs | Datadog PR Page | Give us feedback! |
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
|
|
I'm converting back to draft in order to take a closer look at unsafe code/unbound reads and see if we can avoid them. |
1c21a90 to
33e085c
Compare
51de208 to
bf5f3db
Compare
42a7a66 to
24c7734
Compare
bf5f3db to
f4e473e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4e473edf5
ℹ️ 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".
173ccbc to
e0053c8
Compare
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>
7658fe2 to
a4c5953
Compare
There was a problem hiding this comment.
There are a few issues with this implementation across the board which would be a bit difficult to explain so I just opened a PR on top of this PR instead: #2105
Feel free to reimplement based on the summary if that's easier, I thought it would be a smaller change when I started on it 😅
|
@rochdev would that be ok to just merge this one first (after addressing reviews) and then proceed with your PR? I don't expect to do a lot of modifications and the code isn't used anywhere yet anyway. That'll just make for an easier review experience. If yes, please lift the request for changes. |
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.