-
Notifications
You must be signed in to change notification settings - Fork 324
Replace JCTools queues with VarHandle-based implementations for Java 9+ #9896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
Debugger benchmarksParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 10 metrics, 5 unstable metrics. See unchanged results
Request duration reports for reportsgantt
title reports - request duration [CI 0.99] : candidate=None, baseline=None
dateFormat X
axisFormat %s
section baseline
noprobe (317.508 µs) : 291, 344
. : milestone, 318,
basic (294.053 µs) : 287, 301
. : milestone, 294,
loop (8.959 ms) : 8956, 8963
. : milestone, 8959,
section candidate
noprobe (319.585 µs) : 290, 349
. : milestone, 320,
basic (293.196 µs) : 286, 300
. : milestone, 293,
loop (8.955 ms) : 8952, 8958
. : milestone, 8955,
|
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 56 metrics, 9 unstable metrics. Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.57.0-SNAPSHOT~44fc5dac2b, baseline=1.58.0-SNAPSHOT~b4a047ea27
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.089 s) : 0, 1088697
Total [baseline] (10.966 s) : 0, 10965523
Agent [candidate] (1.095 s) : 0, 1095206
Total [candidate] (10.973 s) : 0, 10973014
section appsec
Agent [baseline] (1.264 s) : 0, 1264253
Total [baseline] (10.952 s) : 0, 10951867
Agent [candidate] (1.26 s) : 0, 1259682
Total [candidate] (10.983 s) : 0, 10982891
section iast
Agent [baseline] (1.232 s) : 0, 1232252
Total [baseline] (11.158 s) : 0, 11157815
Agent [candidate] (1.221 s) : 0, 1221036
Total [candidate] (11.131 s) : 0, 11130997
section profiling
Agent [baseline] (1.213 s) : 0, 1213326
Total [baseline] (10.925 s) : 0, 10925302
Agent [candidate] (1.203 s) : 0, 1203467
Total [candidate] (10.906 s) : 0, 10905786
gantt
title petclinic - break down per module: candidate=1.57.0-SNAPSHOT~44fc5dac2b, baseline=1.58.0-SNAPSHOT~b4a047ea27
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.195 ms) : 0, 1195
crashtracking [candidate] (1.192 ms) : 0, 1192
BytebuddyAgent [baseline] (653.202 ms) : 0, 653202
BytebuddyAgent [candidate] (659.819 ms) : 0, 659819
GlobalTracer [baseline] (283.351 ms) : 0, 283351
GlobalTracer [candidate] (282.115 ms) : 0, 282115
AppSec [baseline] (32.664 ms) : 0, 32664
AppSec [candidate] (33.294 ms) : 0, 33294
Debugger [baseline] (68.991 ms) : 0, 68991
Debugger [candidate] (69.374 ms) : 0, 69374
Remote Config [baseline] (635.265 µs) : 0, 635
Remote Config [candidate] (629.804 µs) : 0, 630
Telemetry [baseline] (9.198 ms) : 0, 9198
Telemetry [candidate] (9.183 ms) : 0, 9183
Flare Poller [baseline] (3.793 ms) : 0, 3793
Flare Poller [candidate] (3.791 ms) : 0, 3791
section appsec
crashtracking [baseline] (1.17 ms) : 0, 1170
crashtracking [candidate] (1.178 ms) : 0, 1178
BytebuddyAgent [baseline] (690.386 ms) : 0, 690386
BytebuddyAgent [candidate] (690.554 ms) : 0, 690554
GlobalTracer [baseline] (258.211 ms) : 0, 258211
GlobalTracer [candidate] (253.634 ms) : 0, 253634
IAST [baseline] (24.589 ms) : 0, 24589
IAST [candidate] (24.365 ms) : 0, 24365
AppSec [baseline] (173.126 ms) : 0, 173126
AppSec [candidate] (174.209 ms) : 0, 174209
Debugger [baseline] (67.325 ms) : 0, 67325
Debugger [candidate] (65.092 ms) : 0, 65092
Remote Config [baseline] (824.503 µs) : 0, 825
Remote Config [candidate] (797.586 µs) : 0, 798
Telemetry [baseline] (9.562 ms) : 0, 9562
Telemetry [candidate] (10.956 ms) : 0, 10956
Flare Poller [baseline] (3.767 ms) : 0, 3767
Flare Poller [candidate] (3.662 ms) : 0, 3662
section iast
crashtracking [baseline] (1.193 ms) : 0, 1193
crashtracking [candidate] (1.175 ms) : 0, 1175
BytebuddyAgent [baseline] (797.824 ms) : 0, 797824
BytebuddyAgent [candidate] (791.861 ms) : 0, 791861
GlobalTracer [baseline] (257.522 ms) : 0, 257522
GlobalTracer [candidate] (252.617 ms) : 0, 252617
IAST [baseline] (27.165 ms) : 0, 27165
IAST [candidate] (26.913 ms) : 0, 26913
AppSec [baseline] (34.858 ms) : 0, 34858
AppSec [candidate] (35.613 ms) : 0, 35613
Debugger [baseline] (65.447 ms) : 0, 65447
Debugger [candidate] (64.788 ms) : 0, 64788
Remote Config [baseline] (622.351 µs) : 0, 622
Remote Config [candidate] (615.507 µs) : 0, 616
Telemetry [baseline] (8.566 ms) : 0, 8566
Telemetry [candidate] (8.477 ms) : 0, 8477
Flare Poller [baseline] (3.585 ms) : 0, 3585
Flare Poller [candidate] (3.529 ms) : 0, 3529
section profiling
crashtracking [baseline] (1.225 ms) : 0, 1225
crashtracking [candidate] (1.212 ms) : 0, 1212
BytebuddyAgent [baseline] (709.186 ms) : 0, 709186
BytebuddyAgent [candidate] (704.643 ms) : 0, 704643
GlobalTracer [baseline] (222.117 ms) : 0, 222117
GlobalTracer [candidate] (216.816 ms) : 0, 216816
AppSec [baseline] (32.566 ms) : 0, 32566
AppSec [candidate] (32.457 ms) : 0, 32457
Debugger [baseline] (68.394 ms) : 0, 68394
Debugger [candidate] (68.236 ms) : 0, 68236
Remote Config [baseline] (630.917 µs) : 0, 631
Remote Config [candidate] (633.964 µs) : 0, 634
Telemetry [baseline] (8.75 ms) : 0, 8750
Telemetry [candidate] (8.79 ms) : 0, 8790
Flare Poller [baseline] (3.671 ms) : 0, 3671
Flare Poller [candidate] (3.686 ms) : 0, 3686
ProfilingAgent [baseline] (96.621 ms) : 0, 96621
ProfilingAgent [candidate] (97.127 ms) : 0, 97127
Profiling [baseline] (97.205 ms) : 0, 97205
Profiling [candidate] (97.713 ms) : 0, 97713
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.57.0-SNAPSHOT~44fc5dac2b, baseline=1.58.0-SNAPSHOT~b4a047ea27
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.091 s) : 0, 1091489
Total [baseline] (8.77 s) : 0, 8770087
Agent [candidate] (1.08 s) : 0, 1080483
Total [candidate] (8.732 s) : 0, 8732330
section iast
Agent [baseline] (1.229 s) : 0, 1229186
Total [baseline] (9.348 s) : 0, 9348018
Agent [candidate] (1.216 s) : 0, 1215943
Total [candidate] (9.291 s) : 0, 9290782
gantt
title insecure-bank - break down per module: candidate=1.57.0-SNAPSHOT~44fc5dac2b, baseline=1.58.0-SNAPSHOT~b4a047ea27
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.192 ms) : 0, 1192
crashtracking [candidate] (1.187 ms) : 0, 1187
BytebuddyAgent [baseline] (656.373 ms) : 0, 656373
BytebuddyAgent [candidate] (650.873 ms) : 0, 650873
GlobalTracer [baseline] (284.371 ms) : 0, 284371
GlobalTracer [candidate] (278.91 ms) : 0, 278910
AppSec [baseline] (32.864 ms) : 0, 32864
AppSec [candidate] (32.687 ms) : 0, 32687
Debugger [baseline] (67.545 ms) : 0, 67545
Debugger [candidate] (66.092 ms) : 0, 66092
Remote Config [baseline] (614.553 µs) : 0, 615
Remote Config [candidate] (615.63 µs) : 0, 616
Telemetry [baseline] (9.08 ms) : 0, 9080
Telemetry [candidate] (10.719 ms) : 0, 10719
Flare Poller [baseline] (3.781 ms) : 0, 3781
Flare Poller [candidate] (3.831 ms) : 0, 3831
section iast
crashtracking [baseline] (1.209 ms) : 0, 1209
crashtracking [candidate] (1.188 ms) : 0, 1188
BytebuddyAgent [baseline] (795.944 ms) : 0, 795944
BytebuddyAgent [candidate] (789.387 ms) : 0, 789387
GlobalTracer [baseline] (256.904 ms) : 0, 256904
GlobalTracer [candidate] (251.419 ms) : 0, 251419
IAST [baseline] (27.314 ms) : 0, 27314
IAST [candidate] (26.767 ms) : 0, 26767
AppSec [baseline] (32.753 ms) : 0, 32753
AppSec [candidate] (35.441 ms) : 0, 35441
Debugger [baseline] (66.875 ms) : 0, 66875
Debugger [candidate] (63.886 ms) : 0, 63886
Remote Config [baseline] (587.583 µs) : 0, 588
Remote Config [candidate] (579.568 µs) : 0, 580
Telemetry [baseline] (8.507 ms) : 0, 8507
Telemetry [candidate] (8.498 ms) : 0, 8498
Flare Poller [baseline] (3.585 ms) : 0, 3585
Flare Poller [candidate] (3.513 ms) : 0, 3513
LoadParameters
See matching parameters
SummaryFound 3 performance improvements and 0 performance regressions! Performance is the same for 17 metrics, 16 unstable metrics.
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.57.0-SNAPSHOT~44fc5dac2b, baseline=1.58.0-SNAPSHOT~b4a047ea27
dateFormat X
axisFormat %s
section baseline
no_agent (1.237 ms) : 1225, 1249
. : milestone, 1237,
iast (3.179 ms) : 3142, 3215
. : milestone, 3179,
iast_FULL (5.839 ms) : 5780, 5898
. : milestone, 5839,
iast_GLOBAL (3.57 ms) : 3515, 3626
. : milestone, 3570,
profiling (2.053 ms) : 2034, 2073
. : milestone, 2053,
tracing (1.764 ms) : 1750, 1779
. : milestone, 1764,
section candidate
no_agent (1.189 ms) : 1178, 1201
. : milestone, 1189,
iast (3.045 ms) : 3012, 3079
. : milestone, 3045,
iast_FULL (5.709 ms) : 5652, 5765
. : milestone, 5709,
iast_GLOBAL (3.503 ms) : 3445, 3562
. : milestone, 3503,
profiling (2.016 ms) : 1998, 2034
. : milestone, 2016,
tracing (1.79 ms) : 1774, 1805
. : milestone, 1790,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.57.0-SNAPSHOT~44fc5dac2b, baseline=1.58.0-SNAPSHOT~b4a047ea27
dateFormat X
axisFormat %s
section baseline
no_agent (19.084 ms) : 18887, 19281
. : milestone, 19084,
appsec (18.812 ms) : 18619, 19005
. : milestone, 18812,
code_origins (17.78 ms) : 17605, 17955
. : milestone, 17780,
iast (17.588 ms) : 17411, 17765
. : milestone, 17588,
profiling (19.57 ms) : 19373, 19766
. : milestone, 19570,
tracing (17.982 ms) : 17799, 18165
. : milestone, 17982,
section candidate
no_agent (17.112 ms) : 16940, 17283
. : milestone, 17112,
appsec (18.503 ms) : 18314, 18693
. : milestone, 18503,
code_origins (17.817 ms) : 17640, 17994
. : milestone, 17817,
iast (17.565 ms) : 17390, 17741
. : milestone, 17565,
profiling (18.44 ms) : 18257, 18623
. : milestone, 18440,
tracing (17.486 ms) : 17312, 17660
. : milestone, 17486,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 11 metrics, 1 unstable metrics. Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.57.0-SNAPSHOT~44fc5dac2b, baseline=1.58.0-SNAPSHOT~b4a047ea27
dateFormat X
axisFormat %s
section baseline
no_agent (1.48 ms) : 1469, 1492
. : milestone, 1480,
appsec (3.661 ms) : 3446, 3877
. : milestone, 3661,
iast (2.216 ms) : 2152, 2280
. : milestone, 2216,
iast_GLOBAL (2.257 ms) : 2191, 2323
. : milestone, 2257,
profiling (2.058 ms) : 2006, 2111
. : milestone, 2058,
tracing (2.045 ms) : 1994, 2096
. : milestone, 2045,
section candidate
no_agent (1.475 ms) : 1464, 1487
. : milestone, 1475,
appsec (3.657 ms) : 3443, 3871
. : milestone, 3657,
iast (2.205 ms) : 2140, 2269
. : milestone, 2205,
iast_GLOBAL (2.255 ms) : 2190, 2320
. : milestone, 2255,
profiling (2.102 ms) : 2047, 2156
. : milestone, 2102,
tracing (2.05 ms) : 1999, 2101
. : milestone, 2050,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.57.0-SNAPSHOT~44fc5dac2b, baseline=1.58.0-SNAPSHOT~b4a047ea27
dateFormat X
axisFormat %s
section baseline
no_agent (14.96 s) : 14960000, 14960000
. : milestone, 14960000,
appsec (14.618 s) : 14618000, 14618000
. : milestone, 14618000,
iast (17.938 s) : 17938000, 17938000
. : milestone, 17938000,
iast_GLOBAL (17.961 s) : 17961000, 17961000
. : milestone, 17961000,
profiling (14.792 s) : 14792000, 14792000
. : milestone, 14792000,
tracing (14.426 s) : 14426000, 14426000
. : milestone, 14426000,
section candidate
no_agent (15.512 s) : 15512000, 15512000
. : milestone, 15512000,
appsec (14.397 s) : 14397000, 14397000
. : milestone, 14397000,
iast (18.269 s) : 18269000, 18269000
. : milestone, 18269000,
iast_GLOBAL (17.884 s) : 17884000, 17884000
. : milestone, 17884000,
profiling (14.614 s) : 14614000, 14614000
. : milestone, 14614000,
tracing (14.683 s) : 14683000, 14683000
. : milestone, 14683000,
|
229f67a to
374d13d
Compare
21e0a65 to
259eeb5
Compare
|
Hi! 👋 Thanks for your pull request! 🎉 To help us review it, please make sure to:
If you need help, please check our contributing guidelines. |
9e7acbe to
b2850b3
Compare
|
Hi @amarziali I am one of the developers of JCTools and we are super happy if we could bring a var handle generation variant in our lib as well. Note: JCTools is at the very core of other frameworks which will soon hit the "no unsafe world" JVM barrier, including Netty. |
utils/queue-utils/src/main/java/datadog/common/queue/BaseQueue.java
Outdated
Show resolved
Hide resolved
85b0dcd to
fc49419
Compare
fc49419 to
183fc37
Compare
This reverts commit 14cc597.
38d8e7f to
438a50b
Compare
What Does This Do
This PR introduces a set of queue implementations in order to replace the JCTools-based queues, eliminating direct usage of sun.misc.Unsafe and providing full compatibility with Java 9+ runtimes through the VarHandle API.
The goal is to achieve similar high-performance concurrent queue behavior as JCTools while using supported, standard Java mechanisms.
A new
Queuesfactory class is introduced to dynamically select the optimal queue implementation based on the Java runtime environment:Introduced Classes Summary
SpscArrayQueueVarHandleSpmcArrayQueueVarHandleMpscArrayQueueVarHandle<E>MpscBlockingConsumerArrayQueueVarHandle<E>Memory Padding
All queue state fields (
head,tail, cached limits, etc.) are cache-line padded to prevent false sharing between producers and consumers.This ensures that frequently accessed hot fields do not reside on the same cache line across threads, minimizing cache invalidations and improving throughput under contention.
Memory Ordering Semantics
VarHandle access modes are carefully chosen to balance performance and correctness, using the weakest ordering that maintains visibility guarantees:
setRelease/getAcquire— Element publication and consumption. Release stores guarantee all preceding writes are visible before the element, while acquire loads ensure all subsequent reads see the published data. Provides efficient producer-consumer synchronization without full memory barriers.getOpaque— Hot-path reads of cached limits and blocked state. Ensures atomic access and eventual visibility without memory fence overhead. Safe when stale reads are benign (e.g., cachedproducerLimittriggers recalculation on mismatch, or when subsequent CAS provides full synchronization).getVolatile— Synchronization points requiring immediate visibility. Used when refreshing producer/consumer limits or checking queue state where correctness depends on seeing the latest value from other threads. Provides sequential consistency with full memory barriers.get/set) — Single-threaded paths where no inter-thread coordination is needed (e.g., single consumer reading its own index).Queue Benchmark Results
SPSC (Single-Producer / Single-Consumer)
Capacity = 1024
Capacity = 65536
MPSC (Multi-Producer / Single-Consumer)
Capacity = 1024
Capacity = 65536
MPSC (Blocking Consumer)
Capacity = 1024
Capacity = 65536
Takeaways:
Motivation
Additional Notes
Contributor Checklist
type:and (comp:orinst:) labels in addition to any useful labelsclose,fixor any linking keywords when referencing an issue.Use
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]