Repository navigation
Add all-native ThreadContextBenchmark and refresh its report - #904
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
More details
The benchmark calls match the current native context API, and the reproduction procedure accounts for runner defaults and duplicate debug/release library entries. The reported timings were not independently rerun.
🤖 Bits Code Review · Commit a92490c
CI Test ResultsRun: #40316770477 | Commit:
Status Overview
Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled Summary: Total: 32 | Passed: 32 | Failed: 0 Updated: 2026-10-26 12:01:10 UTC |
What does this PR do?:
ThreadContextBenchmarkfor the all-native context write API (setTraceContext,setContextValue,clearTraceContext). The class replaces the benchmark that Remove legacy DirectByteBuffer-based OTEP context storage (Phase 3) #696 deleted together withThreadContext.doc/performance/reports/ThreadContextBenchmark.mdwith a three-way comparison on one Linux x86_64 host: JNI (pre-2026-04-08), ByteBuffer (Add OTEP #4947 OTEL-compatible context storage #347 to Remove legacy DirectByteBuffer-based OTEP context storage (Phase 3) #696), and all-native (current).setContextFullsetAttrCacheHitspanLifecycleMotivation:
The report measured only the ByteBuffer implementation, on a laptop. #696 removed that implementation and its benchmark, so the current write path had no benchmark and no current numbers.
The all-native implementation is about 2x slower than the ByteBuffer implementation. It is 1.2x to 2.8x faster than the JNI implementation, but the JNI
put()did different work per call (it kept the custom attributes). None of the three implementations shows false sharing from 1 to 4 threads.Additional Notes:
86367c704.ThreadContextno longer exists, so that source cannot be in the tree.counter++ % 5, which throws after 2^31 calls on one thread. The benchmark also stops the profiler and deletes its JFR file in a trial@TearDown.jmh {}block overrides the class annotations.stresstests.jarcontains both the debug and the releaselibjavaProfilerunder the same entry name.The procedure runs the jar directly, with the release library only.
/code-review(high). Sphinx was unavailable. The first pass found 10 issues, and this PR fixes all of them. The second pass ran over the fixed diff and found 7 issues. This PR fixes 4 of them: the javadoc and the procedure now name the jarMaindefaults, the report notes that the JNI comparison covers different work, and the cost model is marked as an estimate. 3 are declined:spanLifecyclehelper. The committed benchmark stays identical to the code that produced the numbers.How to test the change?:
:ddprof-stresstest:compileJmhJavaand:ddprof-lib:qualityCheckspass.:ddprof-stresstest:jmhJar, keep only the release library in the jar, and runjava -jar bench.jar 'ThreadContextBenchmark' -f 2 -wi 3 -w 1s -i 5 -r 2s -tu ns -bm avgt.For Datadog employees:
credentials of any kind, I've requested a security review (run the
dd:platform-security-reviewskill, or file a request via the PSEC review form).
bewairealso runs automatically on every PR.Unsure? Have a question? Request a review!
🤖 Generated with Claude Code