-
Notifications
You must be signed in to change notification settings - Fork 315
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
|
🎯 Code Coverage 🔗 Commit SHA: b2850b3 | Docs | Datadog PR Page | Was this helpful? Give us feedback! |
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 3 performance improvements and 0 performance regressions! Performance is the same for 50 metrics, 12 unstable metrics.
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.56.0-SNAPSHOT~b2850b3848, baseline=1.56.0-SNAPSHOT~c6e7fcaefe
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.048 s) : 0, 1047668
Total [baseline] (10.799 s) : 0, 10799349
Agent [candidate] (1.042 s) : 0, 1042436
Total [candidate] (10.731 s) : 0, 10731401
section appsec
Agent [baseline] (1.223 s) : 0, 1222923
Total [baseline] (10.874 s) : 0, 10873828
Agent [candidate] (1.215 s) : 0, 1214951
Total [candidate] (10.913 s) : 0, 10913190
section iast
Agent [baseline] (1.188 s) : 0, 1187933
Total [baseline] (11.162 s) : 0, 11161894
Agent [candidate] (1.181 s) : 0, 1181369
Total [candidate] (11.172 s) : 0, 11171639
section profiling
Agent [baseline] (1.203 s) : 0, 1202748
Total [baseline] (10.864 s) : 0, 10863584
Agent [candidate] (1.186 s) : 0, 1185665
Total [candidate] (10.843 s) : 0, 10843404
gantt
title petclinic - break down per module: candidate=1.56.0-SNAPSHOT~b2850b3848, baseline=1.56.0-SNAPSHOT~c6e7fcaefe
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.458 ms) : 0, 1458
crashtracking [candidate] (1.447 ms) : 0, 1447
BytebuddyAgent [baseline] (705.046 ms) : 0, 705046
BytebuddyAgent [candidate] (705.249 ms) : 0, 705249
GlobalTracer [baseline] (246.136 ms) : 0, 246136
GlobalTracer [candidate] (240.149 ms) : 0, 240149
AppSec [baseline] (32.341 ms) : 0, 32341
AppSec [candidate] (32.686 ms) : 0, 32686
Debugger [baseline] (6.416 ms) : 0, 6416
Debugger [candidate] (6.341 ms) : 0, 6341
Remote Config [baseline] (712.105 µs) : 0, 712
Remote Config [candidate] (693.261 µs) : 0, 693
Telemetry [baseline] (15.168 ms) : 0, 15168
Telemetry [candidate] (10.282 ms) : 0, 10282
Flare Poller [baseline] (5.745 ms) : 0, 5745
Flare Poller [candidate] (10.869 ms) : 0, 10869
section appsec
crashtracking [baseline] (1.448 ms) : 0, 1448
crashtracking [candidate] (1.452 ms) : 0, 1452
BytebuddyAgent [baseline] (729.334 ms) : 0, 729334
BytebuddyAgent [candidate] (728.516 ms) : 0, 728516
GlobalTracer [baseline] (237.665 ms) : 0, 237665
GlobalTracer [candidate] (231.602 ms) : 0, 231602
IAST [baseline] (24.899 ms) : 0, 24899
IAST [candidate] (24.78 ms) : 0, 24780
AppSec [baseline] (175.365 ms) : 0, 175365
AppSec [candidate] (174.025 ms) : 0, 174025
Debugger [baseline] (6.043 ms) : 0, 6043
Debugger [candidate] (6.092 ms) : 0, 6092
Remote Config [baseline] (653.456 µs) : 0, 653
Remote Config [candidate] (646.716 µs) : 0, 647
Telemetry [baseline] (8.565 ms) : 0, 8565
Telemetry [candidate] (8.852 ms) : 0, 8852
Flare Poller [baseline] (4.014 ms) : 0, 4014
Flare Poller [candidate] (4.188 ms) : 0, 4188
section iast
crashtracking [baseline] (1.468 ms) : 0, 1468
crashtracking [candidate] (1.455 ms) : 0, 1455
BytebuddyAgent [baseline] (834.403 ms) : 0, 834403
BytebuddyAgent [candidate] (834.469 ms) : 0, 834469
GlobalTracer [baseline] (236.001 ms) : 0, 236001
GlobalTracer [candidate] (229.967 ms) : 0, 229967
IAST [baseline] (32.52 ms) : 0, 32520
IAST [candidate] (34.469 ms) : 0, 34469
AppSec [baseline] (29.091 ms) : 0, 29091
AppSec [candidate] (27.246 ms) : 0, 27246
Debugger [baseline] (6.103 ms) : 0, 6103
Debugger [candidate] (6.034 ms) : 0, 6034
Remote Config [baseline] (610.055 µs) : 0, 610
Remote Config [candidate] (593.606 µs) : 0, 594
Telemetry [baseline] (8.574 ms) : 0, 8574
Telemetry [candidate] (8.39 ms) : 0, 8390
Flare Poller [baseline] (4.22 ms) : 0, 4220
Flare Poller [candidate] (3.928 ms) : 0, 3928
section profiling
crashtracking [baseline] (1.464 ms) : 0, 1464
crashtracking [candidate] (1.436 ms) : 0, 1436
BytebuddyAgent [baseline] (735.476 ms) : 0, 735476
BytebuddyAgent [candidate] (728.853 ms) : 0, 728853
GlobalTracer [baseline] (223.769 ms) : 0, 223769
GlobalTracer [candidate] (215.488 ms) : 0, 215488
AppSec [baseline] (32.526 ms) : 0, 32526
AppSec [candidate] (32.06 ms) : 0, 32060
Debugger [baseline] (7.599 ms) : 0, 7599
Debugger [candidate] (6.475 ms) : 0, 6475
Remote Config [baseline] (1.51 ms) : 0, 1510
Remote Config [candidate] (683.477 µs) : 0, 683
Telemetry [baseline] (14.397 ms) : 0, 14397
Telemetry [candidate] (15.137 ms) : 0, 15137
Flare Poller [baseline] (4.178 ms) : 0, 4178
Flare Poller [candidate] (4.991 ms) : 0, 4991
ProfilingAgent [baseline] (111.532 ms) : 0, 111532
ProfilingAgent [candidate] (110.947 ms) : 0, 110947
Profiling [baseline] (112.197 ms) : 0, 112197
Profiling [candidate] (111.561 ms) : 0, 111561
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.56.0-SNAPSHOT~b2850b3848, baseline=1.56.0-SNAPSHOT~c6e7fcaefe
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.054 s) : 0, 1053823
Total [baseline] (8.68 s) : 0, 8680381
Agent [candidate] (1.046 s) : 0, 1046036
Total [candidate] (8.659 s) : 0, 8659406
section iast
Agent [baseline] (1.187 s) : 0, 1186520
Total [baseline] (9.295 s) : 0, 9294769
Agent [candidate] (1.174 s) : 0, 1173972
Total [candidate] (9.278 s) : 0, 9278266
gantt
title insecure-bank - break down per module: candidate=1.56.0-SNAPSHOT~b2850b3848, baseline=1.56.0-SNAPSHOT~c6e7fcaefe
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.458 ms) : 0, 1458
crashtracking [candidate] (1.467 ms) : 0, 1467
BytebuddyAgent [baseline] (709.384 ms) : 0, 709384
BytebuddyAgent [candidate] (708.628 ms) : 0, 708628
GlobalTracer [baseline] (247.308 ms) : 0, 247308
GlobalTracer [candidate] (240.629 ms) : 0, 240629
AppSec [baseline] (32.578 ms) : 0, 32578
AppSec [candidate] (32.687 ms) : 0, 32687
Debugger [baseline] (6.48 ms) : 0, 6480
Debugger [candidate] (6.276 ms) : 0, 6276
Remote Config [baseline] (710.109 µs) : 0, 710
Remote Config [candidate] (692.307 µs) : 0, 692
Telemetry [baseline] (14.424 ms) : 0, 14424
Telemetry [candidate] (10.844 ms) : 0, 10844
Flare Poller [baseline] (6.63 ms) : 0, 6630
Flare Poller [candidate] (10.025 ms) : 0, 10025
section iast
crashtracking [baseline] (1.459 ms) : 0, 1459
crashtracking [candidate] (1.457 ms) : 0, 1457
BytebuddyAgent [baseline] (834.052 ms) : 0, 834052
BytebuddyAgent [candidate] (828.557 ms) : 0, 828557
GlobalTracer [baseline] (235.394 ms) : 0, 235394
GlobalTracer [candidate] (229.095 ms) : 0, 229095
AppSec [baseline] (28.927 ms) : 0, 28927
AppSec [candidate] (27.108 ms) : 0, 27108
Debugger [baseline] (6.002 ms) : 0, 6002
Debugger [candidate] (6.025 ms) : 0, 6025
Remote Config [baseline] (604.843 µs) : 0, 605
Remote Config [candidate] (585.825 µs) : 0, 586
Telemetry [baseline] (8.484 ms) : 0, 8484
Telemetry [candidate] (8.408 ms) : 0, 8408
Flare Poller [baseline] (4.08 ms) : 0, 4080
Flare Poller [candidate] (4.008 ms) : 0, 4008
IAST [baseline] (32.626 ms) : 0, 32626
IAST [candidate] (34.192 ms) : 0, 34192
LoadParameters
See matching parameters
SummaryFound 2 performance improvements and 1 performance regressions! Performance is the same for 9 metrics, 12 unstable metrics.
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.56.0-SNAPSHOT~b2850b3848, baseline=1.56.0-SNAPSHOT~c6e7fcaefe
dateFormat X
axisFormat %s
section baseline
no_agent (19.302 ms) : 19107, 19496
. : milestone, 19302,
appsec (18.68 ms) : 18490, 18869
. : milestone, 18680,
code_origins (17.821 ms) : 17645, 17997
. : milestone, 17821,
iast (17.793 ms) : 17615, 17971
. : milestone, 17793,
profiling (18.592 ms) : 18407, 18778
. : milestone, 18592,
tracing (18.859 ms) : 18667, 19050
. : milestone, 18859,
section candidate
no_agent (18.258 ms) : 18072, 18444
. : milestone, 18258,
appsec (18.799 ms) : 18608, 18990
. : milestone, 18799,
code_origins (17.695 ms) : 17519, 17872
. : milestone, 17695,
iast (17.775 ms) : 17596, 17955
. : milestone, 17775,
profiling (19.721 ms) : 19521, 19921
. : milestone, 19721,
tracing (17.734 ms) : 17557, 17910
. : milestone, 17734,
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.56.0-SNAPSHOT~b2850b3848, baseline=1.56.0-SNAPSHOT~c6e7fcaefe
dateFormat X
axisFormat %s
section baseline
no_agent (1.194 ms) : 1183, 1205
. : milestone, 1194,
iast (3.196 ms) : 3156, 3235
. : milestone, 3196,
iast_FULL (5.78 ms) : 5723, 5837
. : milestone, 5780,
iast_GLOBAL (3.483 ms) : 3429, 3537
. : milestone, 3483,
profiling (1.946 ms) : 1930, 1963
. : milestone, 1946,
tracing (1.79 ms) : 1774, 1806
. : milestone, 1790,
section candidate
no_agent (1.201 ms) : 1190, 1213
. : milestone, 1201,
iast (3.169 ms) : 3128, 3211
. : milestone, 3169,
iast_FULL (5.743 ms) : 5686, 5800
. : milestone, 5743,
iast_GLOBAL (3.446 ms) : 3394, 3498
. : milestone, 3446,
profiling (1.913 ms) : 1897, 1928
. : milestone, 1913,
tracing (1.81 ms) : 1795, 1826
. : milestone, 1810,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 10 metrics, 2 unstable metrics. Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.56.0-SNAPSHOT~b2850b3848, baseline=1.56.0-SNAPSHOT~c6e7fcaefe
dateFormat X
axisFormat %s
section baseline
no_agent (15.304 s) : 15304000, 15304000
. : milestone, 15304000,
appsec (14.881 s) : 14881000, 14881000
. : milestone, 14881000,
iast (18.514 s) : 18514000, 18514000
. : milestone, 18514000,
iast_GLOBAL (18.22 s) : 18220000, 18220000
. : milestone, 18220000,
profiling (15.764 s) : 15764000, 15764000
. : milestone, 15764000,
tracing (14.952 s) : 14952000, 14952000
. : milestone, 14952000,
section candidate
no_agent (14.884 s) : 14884000, 14884000
. : milestone, 14884000,
appsec (14.763 s) : 14763000, 14763000
. : milestone, 14763000,
iast (18.4 s) : 18400000, 18400000
. : milestone, 18400000,
iast_GLOBAL (17.906 s) : 17906000, 17906000
. : milestone, 17906000,
profiling (14.929 s) : 14929000, 14929000
. : milestone, 14929000,
tracing (14.808 s) : 14808000, 14808000
. : milestone, 14808000,
Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.56.0-SNAPSHOT~b2850b3848, baseline=1.56.0-SNAPSHOT~c6e7fcaefe
dateFormat X
axisFormat %s
section baseline
no_agent (1.475 ms) : 1463, 1486
. : milestone, 1475,
appsec (3.7 ms) : 3484, 3917
. : milestone, 3700,
iast (2.21 ms) : 2146, 2274
. : milestone, 2210,
iast_GLOBAL (2.254 ms) : 2190, 2318
. : milestone, 2254,
profiling (2.498 ms) : 2326, 2670
. : milestone, 2498,
tracing (2.019 ms) : 1969, 2068
. : milestone, 2019,
section candidate
no_agent (1.476 ms) : 1464, 1487
. : milestone, 1476,
appsec (3.672 ms) : 3459, 3886
. : milestone, 3672,
iast (2.209 ms) : 2145, 2273
. : milestone, 2209,
iast_GLOBAL (2.255 ms) : 2191, 2319
. : milestone, 2255,
profiling (2.053 ms) : 2002, 2104
. : milestone, 2053,
tracing (2.028 ms) : 1978, 2078
. : milestone, 2028,
|
229f67a to
374d13d
Compare
This reverts commit 14cc597.
2721d41 to
0a72587
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. |
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
SpscArrayQueueVarHandleSpmcArrayQueueVarHandleconsumerLimitcaching to reduce volatile contention.MpscArrayQueueVarHandle<E>TAIL_HANDLE. Maintains aproducerLimitto minimize volatile head reads.MpscBlockingConsumerArrayQueueVarHandle<E>CONSUMER_THREAD_HANDLEto park/unpark the waiting consumer efficiently.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 Fence Semantics
Memory fences were explicitly chosen for each access type to minimize volatile overhead while maintaining correct visibility guarantees:
setRelease/getAcquirefor publishing and consuming elements — provides correct inter-thread ordering without full barriers.setOpaque/getOpaquefor relaxed head/tail updates — avoids unnecessary synchronization costs where ordering is not required.getVolatileonly used when full memory fences are really required (e.g. refreshing limits to ensure visibility when the queue might be full or empty).Queue Benchmark Results (ops/us)
Note: SPSC benchmark shows contentions on slow path (i.e. queue is full/queue is empty). This should less frequently happen in our case. Increasing the queue size (hence reducing the probability that's full) shows good performances.
MPSCBlockingConsumer Queue Benchmark (ops/us)
MPSC Queue Benchmark (ops/us)
SPSC Queue Benchmark (ops/us)
Takeaways:
Room for future improvements
In high-throughput scenarios where multiple producers compete for queue space, contention on the CAS operation can become a bottleneck.
Idea to mitigate this, when the queue is likely not full, a
getAndAddoperation can be used instead of a CAS to claim slots since it will never fail. This optimization allows multiple producers to advance the tail index with reduced atomic contention. However, when the queue is nearly full, the getAndAdd cannot be reliably done hence the classic CAS loop (slow path) can be used instead.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]