-
Notifications
You must be signed in to change notification settings - Fork 319
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 1 performance improvements and 1 performance regressions! Performance is the same for 57 metrics, 6 unstable metrics.
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.57.0-SNAPSHOT~438a50b187, baseline=1.57.0-SNAPSHOT~015be6d1b3
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.078 s) : 0, 1077594
Total [baseline] (10.904 s) : 0, 10903955
Agent [candidate] (1.08 s) : 0, 1080092
Total [candidate] (10.825 s) : 0, 10824822
section appsec
Agent [baseline] (1.265 s) : 0, 1264744
Total [baseline] (11.13 s) : 0, 11130052
Agent [candidate] (1.261 s) : 0, 1260598
Total [candidate] (11.014 s) : 0, 11014300
section iast
Agent [baseline] (1.223 s) : 0, 1222540
Total [baseline] (11.173 s) : 0, 11173393
Agent [candidate] (1.218 s) : 0, 1217973
Total [candidate] (11.23 s) : 0, 11229924
section profiling
Agent [baseline] (1.205 s) : 0, 1205411
Total [baseline] (11.099 s) : 0, 11098609
Agent [candidate] (1.204 s) : 0, 1203977
Total [candidate] (10.93 s) : 0, 10930217
gantt
title petclinic - break down per module: candidate=1.57.0-SNAPSHOT~438a50b187, baseline=1.57.0-SNAPSHOT~015be6d1b3
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.202 ms) : 0, 1202
crashtracking [candidate] (1.187 ms) : 0, 1187
BytebuddyAgent [baseline] (646.593 ms) : 0, 646593
BytebuddyAgent [candidate] (649.461 ms) : 0, 649461
GlobalTracer [baseline] (281.087 ms) : 0, 281087
GlobalTracer [candidate] (278.588 ms) : 0, 278588
AppSec [baseline] (32.255 ms) : 0, 32255
AppSec [candidate] (32.572 ms) : 0, 32572
Debugger [baseline] (67.799 ms) : 0, 67799
Debugger [candidate] (69.27 ms) : 0, 69270
Remote Config [baseline] (634.214 µs) : 0, 634
Remote Config [candidate] (644.822 µs) : 0, 645
Telemetry [baseline] (8.901 ms) : 0, 8901
Telemetry [candidate] (9.033 ms) : 0, 9033
Flare Poller [baseline] (3.676 ms) : 0, 3676
Flare Poller [candidate] (3.769 ms) : 0, 3769
section appsec
crashtracking [baseline] (1.196 ms) : 0, 1196
crashtracking [candidate] (1.205 ms) : 0, 1205
BytebuddyAgent [baseline] (688.866 ms) : 0, 688866
BytebuddyAgent [candidate] (688.395 ms) : 0, 688395
GlobalTracer [baseline] (259.303 ms) : 0, 259303
GlobalTracer [candidate] (255.621 ms) : 0, 255621
AppSec [baseline] (174.963 ms) : 0, 174963
AppSec [candidate] (175.243 ms) : 0, 175243
Debugger [baseline] (66.576 ms) : 0, 66576
Debugger [candidate] (58.621 ms) : 0, 58621
Remote Config [baseline] (756.674 µs) : 0, 757
Remote Config [candidate] (719.047 µs) : 0, 719
Telemetry [baseline] (9.097 ms) : 0, 9097
Telemetry [candidate] (15.132 ms) : 0, 15132
Flare Poller [baseline] (3.955 ms) : 0, 3955
Flare Poller [candidate] (5.892 ms) : 0, 5892
IAST [baseline] (24.536 ms) : 0, 24536
IAST [candidate] (24.393 ms) : 0, 24393
section iast
crashtracking [baseline] (1.184 ms) : 0, 1184
crashtracking [candidate] (1.188 ms) : 0, 1188
BytebuddyAgent [baseline] (790.39 ms) : 0, 790390
BytebuddyAgent [candidate] (790.457 ms) : 0, 790457
GlobalTracer [baseline] (255.552 ms) : 0, 255552
GlobalTracer [candidate] (251.675 ms) : 0, 251675
AppSec [baseline] (34.483 ms) : 0, 34483
AppSec [candidate] (36.024 ms) : 0, 36024
Debugger [baseline] (66.178 ms) : 0, 66178
Debugger [candidate] (64.171 ms) : 0, 64171
Remote Config [baseline] (532.623 µs) : 0, 533
Remote Config [candidate] (532.859 µs) : 0, 533
Telemetry [baseline] (8.428 ms) : 0, 8428
Telemetry [candidate] (8.415 ms) : 0, 8415
Flare Poller [baseline] (3.531 ms) : 0, 3531
Flare Poller [candidate] (3.648 ms) : 0, 3648
IAST [baseline] (26.873 ms) : 0, 26873
IAST [candidate] (26.731 ms) : 0, 26731
section profiling
ProfilingAgent [baseline] (97.668 ms) : 0, 97668
ProfilingAgent [candidate] (97.765 ms) : 0, 97765
crashtracking [baseline] (1.193 ms) : 0, 1193
crashtracking [candidate] (1.204 ms) : 0, 1204
BytebuddyAgent [baseline] (702.306 ms) : 0, 702306
BytebuddyAgent [candidate] (702.995 ms) : 0, 702995
GlobalTracer [baseline] (220.965 ms) : 0, 220965
GlobalTracer [candidate] (217.399 ms) : 0, 217399
AppSec [baseline] (32.394 ms) : 0, 32394
AppSec [candidate] (32.528 ms) : 0, 32528
Debugger [baseline] (67.89 ms) : 0, 67890
Debugger [candidate] (68.945 ms) : 0, 68945
Remote Config [baseline] (625.544 µs) : 0, 626
Remote Config [candidate] (614.66 µs) : 0, 615
Telemetry [baseline] (8.914 ms) : 0, 8914
Telemetry [candidate] (9.009 ms) : 0, 9009
Flare Poller [baseline] (3.771 ms) : 0, 3771
Flare Poller [candidate] (3.816 ms) : 0, 3816
Profiling [baseline] (98.245 ms) : 0, 98245
Profiling [candidate] (98.347 ms) : 0, 98347
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.57.0-SNAPSHOT~438a50b187, baseline=1.57.0-SNAPSHOT~015be6d1b3
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.092 s) : 0, 1091551
Total [baseline] (8.808 s) : 0, 8808116
Agent [candidate] (1.082 s) : 0, 1082328
Total [candidate] (8.765 s) : 0, 8764922
section iast
Agent [baseline] (1.23 s) : 0, 1230140
Total [baseline] (9.501 s) : 0, 9500835
Agent [candidate] (1.234 s) : 0, 1233834
Total [candidate] (9.413 s) : 0, 9413304
gantt
title insecure-bank - break down per module: candidate=1.57.0-SNAPSHOT~438a50b187, baseline=1.57.0-SNAPSHOT~015be6d1b3
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.215 ms) : 0, 1215
crashtracking [candidate] (1.192 ms) : 0, 1192
BytebuddyAgent [baseline] (656.212 ms) : 0, 656212
BytebuddyAgent [candidate] (651.763 ms) : 0, 651763
GlobalTracer [baseline] (284.119 ms) : 0, 284119
GlobalTracer [candidate] (279.764 ms) : 0, 279764
AppSec [baseline] (32.859 ms) : 0, 32859
AppSec [candidate] (32.413 ms) : 0, 32413
Debugger [baseline] (67.775 ms) : 0, 67775
Debugger [candidate] (68.027 ms) : 0, 68027
Remote Config [baseline] (699.724 µs) : 0, 700
Remote Config [candidate] (638.952 µs) : 0, 639
Telemetry [baseline] (9.06 ms) : 0, 9060
Telemetry [candidate] (9.09 ms) : 0, 9090
Flare Poller [baseline] (3.79 ms) : 0, 3790
Flare Poller [candidate] (3.808 ms) : 0, 3808
section iast
crashtracking [baseline] (1.203 ms) : 0, 1203
crashtracking [candidate] (1.208 ms) : 0, 1208
BytebuddyAgent [baseline] (796.186 ms) : 0, 796186
BytebuddyAgent [candidate] (802.234 ms) : 0, 802234
GlobalTracer [baseline] (257.392 ms) : 0, 257392
GlobalTracer [candidate] (255.149 ms) : 0, 255149
AppSec [baseline] (35.54 ms) : 0, 35540
AppSec [candidate] (35.951 ms) : 0, 35951
Debugger [baseline] (64.606 ms) : 0, 64606
Debugger [candidate] (63.783 ms) : 0, 63783
Remote Config [baseline] (561.034 µs) : 0, 561
Remote Config [candidate] (526.472 µs) : 0, 526
Telemetry [baseline] (8.474 ms) : 0, 8474
Telemetry [candidate] (8.354 ms) : 0, 8354
Flare Poller [baseline] (3.498 ms) : 0, 3498
Flare Poller [candidate] (3.641 ms) : 0, 3641
IAST [baseline] (27.08 ms) : 0, 27080
IAST [candidate] (27.328 ms) : 0, 27328
LoadParameters
See matching parameters
SummaryFound 2 performance improvements and 0 performance regressions! Performance is the same for 18 metrics, 16 unstable metrics.
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.57.0-SNAPSHOT~438a50b187, baseline=1.57.0-SNAPSHOT~015be6d1b3
dateFormat X
axisFormat %s
section baseline
no_agent (18.23 ms) : 18046, 18414
. : milestone, 18230,
appsec (20.626 ms) : 20414, 20838
. : milestone, 20626,
code_origins (17.61 ms) : 17435, 17785
. : milestone, 17610,
iast (17.463 ms) : 17293, 17633
. : milestone, 17463,
profiling (18.782 ms) : 18597, 18966
. : milestone, 18782,
tracing (18.52 ms) : 18333, 18707
. : milestone, 18520,
section candidate
no_agent (18.32 ms) : 18131, 18509
. : milestone, 18320,
appsec (18.947 ms) : 18754, 19141
. : milestone, 18947,
code_origins (17.302 ms) : 17131, 17473
. : milestone, 17302,
iast (17.647 ms) : 17473, 17821
. : milestone, 17647,
profiling (18.787 ms) : 18603, 18971
. : milestone, 18787,
tracing (17.604 ms) : 17429, 17779
. : milestone, 17604,
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.57.0-SNAPSHOT~438a50b187, baseline=1.57.0-SNAPSHOT~015be6d1b3
dateFormat X
axisFormat %s
section baseline
no_agent (1.206 ms) : 1194, 1217
. : milestone, 1206,
iast (3.196 ms) : 3150, 3242
. : milestone, 3196,
iast_FULL (5.801 ms) : 5744, 5858
. : milestone, 5801,
iast_GLOBAL (3.775 ms) : 3710, 3841
. : milestone, 3775,
profiling (2.03 ms) : 2012, 2048
. : milestone, 2030,
tracing (1.86 ms) : 1844, 1877
. : milestone, 1860,
section candidate
no_agent (1.206 ms) : 1194, 1218
. : milestone, 1206,
iast (3.131 ms) : 3093, 3168
. : milestone, 3131,
iast_FULL (5.74 ms) : 5684, 5796
. : milestone, 5740,
iast_GLOBAL (3.612 ms) : 3556, 3669
. : milestone, 3612,
profiling (1.904 ms) : 1889, 1919
. : milestone, 1904,
tracing (1.852 ms) : 1836, 1868
. : milestone, 1852,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 12 metrics, 0 unstable metrics. Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.57.0-SNAPSHOT~438a50b187, baseline=1.57.0-SNAPSHOT~015be6d1b3
dateFormat X
axisFormat %s
section baseline
no_agent (15.007 s) : 15007000, 15007000
. : milestone, 15007000,
appsec (14.404 s) : 14404000, 14404000
. : milestone, 14404000,
iast (18.437 s) : 18437000, 18437000
. : milestone, 18437000,
iast_GLOBAL (17.796 s) : 17796000, 17796000
. : milestone, 17796000,
profiling (14.391 s) : 14391000, 14391000
. : milestone, 14391000,
tracing (14.703 s) : 14703000, 14703000
. : milestone, 14703000,
section candidate
no_agent (15.387 s) : 15387000, 15387000
. : milestone, 15387000,
appsec (14.594 s) : 14594000, 14594000
. : milestone, 14594000,
iast (18.31 s) : 18310000, 18310000
. : milestone, 18310000,
iast_GLOBAL (17.962 s) : 17962000, 17962000
. : milestone, 17962000,
profiling (15.289 s) : 15289000, 15289000
. : milestone, 15289000,
tracing (14.763 s) : 14763000, 14763000
. : milestone, 14763000,
Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.57.0-SNAPSHOT~438a50b187, baseline=1.57.0-SNAPSHOT~015be6d1b3
dateFormat X
axisFormat %s
section baseline
no_agent (1.475 ms) : 1464, 1487
. : milestone, 1475,
appsec (2.455 ms) : 2404, 2507
. : milestone, 2455,
iast (2.215 ms) : 2151, 2279
. : milestone, 2215,
iast_GLOBAL (2.26 ms) : 2195, 2325
. : milestone, 2260,
profiling (2.072 ms) : 2020, 2125
. : milestone, 2072,
tracing (2.052 ms) : 2001, 2102
. : milestone, 2052,
section candidate
no_agent (1.479 ms) : 1467, 1490
. : milestone, 1479,
appsec (2.519 ms) : 2464, 2573
. : milestone, 2519,
iast (2.218 ms) : 2154, 2283
. : milestone, 2218,
iast_GLOBAL (2.249 ms) : 2184, 2314
. : milestone, 2249,
profiling (2.075 ms) : 2022, 2127
. : milestone, 2075,
tracing (2.053 ms) : 2002, 2103
. : milestone, 2053,
|
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]