Repository navigation
Conversation
One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via: Supported
Alternatively, if the co-author should not be included, remove the Please update your commit message(s) by doing |
Pull request dashboard statusWaiting on the author · refreshed 2026-11-26 11:42 UTC Move out of draft to request review. Status above doesn't look right?
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9068 +/- ##
============================================
+ Coverage 90.56% 90.57% +0.01%
Complexity 11220 11220
============================================
Files 1032 1032
Lines 30599 30600 +1
Branches 4010 4012 +2
============================================
+ Hits 27711 27716 +5
+ Misses 1913 1910 -3
+ Partials 975 974 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Expose the worker within its package so tests can pause a supplied queue at the empty-check boundary without reflection. Assisted-by: Codex (GPT-6) Co-Authored-By: Codex (GPT-6) <noreply@openai.com>
Publish and recheck the batch threshold before parking the exporter. Wake it for flush and shutdown, including when flush finishes before shutdown callback registration. Assisted-by: Codex (GPT-6) Co-Authored-By: Codex (GPT-6) <noreply@openai.com>
f31e798 to
ca5fb1c
Compare
Depends on #9070. Merge the benchmark fixes first. This PR contains only the span processor implementation and its worker concurrency tests.
Ending a sampled span on an event-loop thread can park inside
BatchSpanProcessor.Worker.addSpan()whileArrayBlockingQueue.offer()acquires itsReentrantLock. This PR replaces that signal queue withLockSupport.unpark()while retainingDaemonThreadFactoryand interrupt handling.The worker publishes its batch threshold, rechecks queued work and pending flush/shutdown state, and then calls
parkNanos(). Shutdown also wakes the worker when its completion callback runs after the flush has already completed. Related to #8240; this version adds deterministic wake-up/lifecycle tests and before/after benchmarks.This removes the producer-side Java signal-queue lock. HotSpot's native
unparkcan still contend on a mutex. These measurements do not establish a wait-free span-end call.Validation
:sdk:trace:checkpasses using JDK 25, including 356 tests, formatting, static checks, and API comparison.:sdk:trace:test :sdk:trace:testIncubating -PtestJavaVersion=11passes: 326 regular tests and 30 incubating tests.f31e798; splitting the PRs preserves those sources exactly.Methodology, counters, and commands: benchmark README.
JMH results
Apple M4 Pro (14 cores, 48 GiB), macOS 26.7.1, Temurin 11.0.31+11, JMH 1.37. Each case uses three independent forks per variant, 3 × 2s warm-up and 5 × 2s measurement iterations, with the GC profiler. Variant order alternates baseline/patched, patched/baseline, baseline/patched. No builds or other benchmark runs ran concurrently with the measurements.
The identical harness and dependencies are used for both variants. Baseline
BatchSpanProcessorclasses are compiled froma92b644with JDK 25 (--release 8) into a small override jar placed first on the fork classpath. The patched variant uses the main JMH jar. This holds the benchmark fixed without copying or modifying the checkout. The runtime implementation was held fixed while correcting the benchmarks.All values below are median [minimum–maximum] across the three fork results, not confidence intervals. Rates use complete-iteration ledgers through the final drain, including JMH synchronization work around the timed loop. They are not the primary JMH attempt-throughput score. These results supersede the earlier exploratory tables made with the old accounting.
Saturation: successful no-op exporter, queue 2048, batch 512
Export rate increases in every paired fork, while attempt rate decreases; the baseline drops far more work. The improvement includes the publish/recheck race fix; this comparison does not isolate that fix from replacing the signaling primitive.
This is not a CPU-efficiency win under saturation. Median worker CPU rises from 36.8% to 91.2% of one core at five producers and 54.0% to 93.1% at ten. CPU per exported span rises from 116 to 121 ns and 257 to 273 ns respectively. Allocations per attempt also rise with the different accepted/dropped work mix, so these cases do not demonstrate an allocation improvement.
Sampled
Span.end()latency: queue 2048, batch 512, target 5000 spans/s per producerThere are no dropped spans in any latency iteration, including warm-up. Normal-batch achieved rates are 4.94–4.99k/s at one producer and 49.38–49.91k/s at ten; skipped slots stay below 1.1%. P50 is around 125–167 ns, near the invocation/timer overhead floor. The p99.9 reductions are encouraging observations on this host, not bounds on event-loop blocking or evidence about Linux scheduling.
Frequent wake-ups: one producer, batch size 1
Skipped arrival slots, as a percentage of attempted plus skipped arrivals:
The 5000/s case has unequal achieved loads and broad overlapping tail ranges. The 1000/s control was added after observing those missed arrivals. The lower-rate control achieves a closely matched load and still has substantial tails. These samples do not attribute the remaining pauses to a specific cause or establish that native mutex contention has disappeared.
Per-fork results
Reproduce
Apply the benchmark prerequisite #9070 before building these JMH classes. Build the combined tree with JDK 25, then use JDK 11 for the runner and forks:
Repeat three times per variant in alternating order, using separate result files. For frequent wake-ups, select only
BatchSpanProcessorSpanEndBenchmark.end_01Thread, add-p maxExportBatchSize=1, and run targets 5000 and 1000 separately. To reproduce the baseline, compile the originalBatchSpanProcessor.javawithjavac --release 8 -proc:none -cp <jmh-jar>, package all resultingBatchSpanProcessor*.classfiles, and invokeorg.openjdk.jmh.Mainwith that override jar first on the classpath instead of using-jar.AI-assisted implementation, tests, and analysis with Codex (GPT-6), with additional Codex review. Kept as a draft for human review of the concurrency design and benchmark tradeoffs.