Repository navigation
Conversation
f06028b to
bd11ab6
Compare
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
bd11ab6 to
43011f5
Compare
|
@DataDog review |
There was a problem hiding this comment.
More details
Buffered-header extraction retains public-accessor fallbacks for unsupported layouts, subclasses, and Base64 decoding. The completed static review identified no actionable defect, and human PR discussion raised no additional concerns.
🤖 Bits Code Review · Commit 43011f5
Kafka / producer-benchmarkParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics. See unchanged results
|
Kafka / consumer-benchmarkParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics. See unchanged results
|
Codex Review Summary: ✅ CompletedThis 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
Static review found no actionable regression in buffered-header propagation or the public-accessor fallbacks for subclasses and Base64 extraction. Runtime and Kafka-version compatibility remain unverified.
🤖 Bits Code Review · Commit 43011f5
What Does This Do
Achieves the fetched Kafka header allocation savings of #13600 without changing the shape of Kafka’s
RecordHeaderclass. Known propagation keys are read without decoding them, and UTF-8 values are decoded directly from the batch buffer without Kafka’s intermediatebyte[]copy.The buffered-header constructor captures a private lookup once per class loader. Extraction uses getter handles through static-final call-site invokers. This adds no fields, interfaces or accessor methods to
RecordHeader; the advice changes the existing constructor body. Unsupported layouts, subclasses and Base64 extraction retain the public-accessor path.Motivation
Preserve the same allocation-saving read path as #13600 while avoiding its structural instrumentation and
FieldAccessorsprerequisite. The comparison below shows similar allocation and competitive steady-state consumer cost with the constructor approach included.Additional Notes
Comparison with #13600
Local comparison of this branch at
f06028bcc31with #13600 atcdee7363337, on one common tracer/runtime and Kafka 3.8.0 baseline. Only the header access/extractor implementations and their transformations differ.The workload parses fresh serialized 500-record batches, uses Kafka’s
ByteArrayDeserializer, and drainsConsumerRecordsthrough the productionTracingIteratorandCoreTracer, including extraction, decoration, activation and span completion. Each record has six Datadog/W3C headers plus 0/3 application headers, a 100-byte value and a distinct upstream context; 10% are sampled. DSM and time-in-queue are off; applications consume payloads without reading headers afterward.A small premain harness applies the real constructor advice or generated getters to the exact
RecordHeaderclass. No subclass/getter simulation or manually supplied lookup is used. Each fork verifies the buffered fast path and all 500 completed spans’ parents and sampling priorities.Five independent JVM forks per case, serial with alternating implementation order; 5 × 2 s warmup, 7 × 3 s measurement, one thread and the JMH GC profiler. Same macOS arm64 machine, Zulu HotSpot 8u514 / 17.0.21.1 / 21.0.13.1, 512 MiB G1 heap and four JVM-visible CPUs (GC threads 2/1). This measures steady consumer processing with a blackhole writer; startup, broker/network traffic, full client bookkeeping and trace serialization are excluded.
Time is ns/record, mean ± between-fork standard deviation; allocation is B/record.
Allocations are broadly similar. The strongest repeated indication favors this branch on Java 17 with three application headers: all five pairs favor it, averaging about 3.5% lower time. The other configurations remain inconclusive against between-fork variation, particularly on Java 21. These measurements support comparable cost, rather than a general speedup claim over #13600.
Constructor cost and a possible Java 9+ follow-up
The steady-state advice checks a volatile initialization field; capturing the lookup and resolving the four getters happen once per class loader. All branch timings above include the actual advice on every buffered-header construction: six or nine constructor-advice checks per record. With nine headers, the complete branch path takes 2,376 / 2,043 / 2,639 ns per record on Java 8 / 17 / 21, versus 2,387 / 2,117 / 2,682 ns for generated getters. That makes constructor capture look inexpensive in this workload, although this is a whole-path comparison and does not isolate an incremental ns/constructor figure.
We could still consider
MethodHandles.privateLookupInon Java 9+ later, once module access is solved. It works on the ordinary classpath, but a shared class loader does not imply a shared module: injected helpers live in the unnamed module. Across modules, it requires a caller lookup withPRIVATEandMODULEaccess, readability of the target module, and the target package to be open to the caller; exporting it is insufficient. Helper injection adds readability without opening Kafka’s package. Closed named-module deployments therefore need a targeted opening or a retained fallback before constructor capture can be replaced generally. Capturing the lookup inside Kafka’s constructor avoids requiring that package opening.See the privateLookupIn access requirements.
As with #13600, leaving headers lazy can retain backing batch storage longer when applications retain records without reading their headers. This preserves Kafka’s uninstrumented lazy behavior.
Validation
--release 8, with the unrelated Java 17 Spring dependencies excluded; the module’s standard suite has a Java 17 minimum.Contributor Checklist