- 
                Notifications
    You must be signed in to change notification settings 
- Fork 315
Improve support for virtual thread detection #9852
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: 29b3509 | Docs | Was this helpful? Give us feedback! | 
| BenchmarksStartupParameters
 See matching parameters
 SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 54 metrics, 11 unstable metrics. Startup time reports for petclinicgantt
    title petclinic - global startup overhead: candidate=1.55.0-SNAPSHOT~29b3509c96, baseline=1.55.0-SNAPSHOT~f296927f57
    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.033 s) : 0, 1033165
Total [baseline] (10.839 s) : 0, 10839460
Agent [candidate] (1.034 s) : 0, 1034038
Total [candidate] (10.874 s) : 0, 10873513
section appsec
Agent [baseline] (1.216 s) : 0, 1215976
Total [baseline] (11.024 s) : 0, 11023741
Agent [candidate] (1.211 s) : 0, 1211033
Total [candidate] (10.942 s) : 0, 10942040
section iast
Agent [baseline] (1.17 s) : 0, 1169944
Total [baseline] (11.205 s) : 0, 11204540
Agent [candidate] (1.167 s) : 0, 1167471
Total [candidate] (11.135 s) : 0, 11134979
section profiling
Agent [baseline] (1.174 s) : 0, 1174303
Total [baseline] (11.057 s) : 0, 11056562
Agent [candidate] (1.177 s) : 0, 1177355
Total [candidate] (10.907 s) : 0, 10906766
 
 
 
 gantt
    title petclinic - break down per module: candidate=1.55.0-SNAPSHOT~29b3509c96, baseline=1.55.0-SNAPSHOT~f296927f57
    dateFormat X
    axisFormat %s
section tracing
crashtracking [baseline] (1.47 ms) : 0, 1470
crashtracking [candidate] (1.476 ms) : 0, 1476
BytebuddyAgent [baseline] (703.659 ms) : 0, 703659
BytebuddyAgent [candidate] (705.946 ms) : 0, 705946
GlobalTracer [baseline] (245.919 ms) : 0, 245919
GlobalTracer [candidate] (244.969 ms) : 0, 244969
AppSec [baseline] (32.533 ms) : 0, 32533
AppSec [candidate] (32.119 ms) : 0, 32119
Debugger [baseline] (6.427 ms) : 0, 6427
Debugger [candidate] (6.365 ms) : 0, 6365
Remote Config [baseline] (680.088 µs) : 0, 680
Remote Config [candidate] (678.272 µs) : 0, 678
Telemetry [baseline] (13.865 ms) : 0, 13865
Telemetry [candidate] (15.315 ms) : 0, 15315
Flare Poller [baseline] (7.37 ms) : 0, 7370
Flare Poller [candidate] (5.793 ms) : 0, 5793
section appsec
crashtracking [baseline] (1.5 ms) : 0, 1500
crashtracking [candidate] (1.469 ms) : 0, 1469
BytebuddyAgent [baseline] (736.554 ms) : 0, 736554
BytebuddyAgent [candidate] (731.528 ms) : 0, 731528
GlobalTracer [baseline] (237.433 ms) : 0, 237433
GlobalTracer [candidate] (237.611 ms) : 0, 237611
IAST [baseline] (25.182 ms) : 0, 25182
IAST [candidate] (25.316 ms) : 0, 25316
AppSec [baseline] (175.077 ms) : 0, 175077
AppSec [candidate] (174.875 ms) : 0, 174875
Debugger [baseline] (5.929 ms) : 0, 5929
Debugger [candidate] (5.931 ms) : 0, 5931
Remote Config [baseline] (623.631 µs) : 0, 624
Remote Config [candidate] (632.551 µs) : 0, 633
Telemetry [baseline] (8.389 ms) : 0, 8389
Telemetry [candidate] (8.525 ms) : 0, 8525
Flare Poller [baseline] (3.88 ms) : 0, 3880
Flare Poller [candidate] (3.897 ms) : 0, 3897
section iast
crashtracking [baseline] (1.475 ms) : 0, 1475
crashtracking [candidate] (1.517 ms) : 0, 1517
BytebuddyAgent [baseline] (830.148 ms) : 0, 830148
BytebuddyAgent [candidate] (828.648 ms) : 0, 828648
GlobalTracer [baseline] (235.279 ms) : 0, 235279
GlobalTracer [candidate] (234.668 ms) : 0, 234668
IAST [baseline] (31.047 ms) : 0, 31047
IAST [candidate] (31.73 ms) : 0, 31730
AppSec [baseline] (30.853 ms) : 0, 30853
AppSec [candidate] (29.971 ms) : 0, 29971
Debugger [baseline] (6.217 ms) : 0, 6217
Debugger [candidate] (6.138 ms) : 0, 6138
Remote Config [baseline] (619.175 µs) : 0, 619
Remote Config [candidate] (610.837 µs) : 0, 611
Telemetry [baseline] (8.626 ms) : 0, 8626
Telemetry [candidate] (8.591 ms) : 0, 8591
Flare Poller [baseline] (4.221 ms) : 0, 4221
Flare Poller [candidate] (4.123 ms) : 0, 4123
section profiling
crashtracking [baseline] (1.46 ms) : 0, 1460
crashtracking [candidate] (1.464 ms) : 0, 1464
BytebuddyAgent [baseline] (726.176 ms) : 0, 726176
BytebuddyAgent [candidate] (729.089 ms) : 0, 729089
GlobalTracer [baseline] (219.914 ms) : 0, 219914
GlobalTracer [candidate] (221.428 ms) : 0, 221428
AppSec [baseline] (32.315 ms) : 0, 32315
AppSec [candidate] (32.319 ms) : 0, 32319
Debugger [baseline] (12.472 ms) : 0, 12472
Debugger [candidate] (12.848 ms) : 0, 12848
Remote Config [baseline] (1.484 ms) : 0, 1484
Remote Config [candidate] (690.095 µs) : 0, 690
Telemetry [baseline] (10.001 ms) : 0, 10001
Telemetry [candidate] (9.866 ms) : 0, 9866
Flare Poller [baseline] (4.172 ms) : 0, 4172
Flare Poller [candidate] (4.135 ms) : 0, 4135
ProfilingAgent [baseline] (111.005 ms) : 0, 111005
ProfilingAgent [candidate] (110.035 ms) : 0, 110035
Profiling [baseline] (111.677 ms) : 0, 111677
Profiling [candidate] (110.685 ms) : 0, 110685
Startup time reports for insecure-bankgantt
    title insecure-bank - global startup overhead: candidate=1.55.0-SNAPSHOT~29b3509c96, baseline=1.55.0-SNAPSHOT~f296927f57
    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.041 s) : 0, 1040849
Total [baseline] (8.679 s) : 0, 8679426
Agent [candidate] (1.033 s) : 0, 1032503
Total [candidate] (8.697 s) : 0, 8697280
section iast
Agent [baseline] (1.163 s) : 0, 1162863
Total [baseline] (9.375 s) : 0, 9374611
Agent [candidate] (1.164 s) : 0, 1164180
Total [candidate] (9.354 s) : 0, 9354247
 
 
 
 gantt
    title insecure-bank - break down per module: candidate=1.55.0-SNAPSHOT~29b3509c96, baseline=1.55.0-SNAPSHOT~f296927f57
    dateFormat X
    axisFormat %s
section tracing
crashtracking [baseline] (1.471 ms) : 0, 1471
crashtracking [candidate] (1.463 ms) : 0, 1463
BytebuddyAgent [baseline] (710.754 ms) : 0, 710754
BytebuddyAgent [candidate] (703.544 ms) : 0, 703544
GlobalTracer [baseline] (246.489 ms) : 0, 246489
GlobalTracer [candidate] (245.848 ms) : 0, 245848
AppSec [baseline] (32.684 ms) : 0, 32684
AppSec [candidate] (32.477 ms) : 0, 32477
Debugger [baseline] (6.395 ms) : 0, 6395
Debugger [candidate] (6.402 ms) : 0, 6402
Remote Config [baseline] (693.467 µs) : 0, 693
Remote Config [candidate] (675.696 µs) : 0, 676
Telemetry [baseline] (14.533 ms) : 0, 14533
Telemetry [candidate] (14.435 ms) : 0, 14435
Flare Poller [baseline] (6.441 ms) : 0, 6441
Flare Poller [candidate] (6.424 ms) : 0, 6424
section iast
crashtracking [baseline] (1.486 ms) : 0, 1486
crashtracking [candidate] (1.471 ms) : 0, 1471
BytebuddyAgent [baseline] (824.376 ms) : 0, 824376
BytebuddyAgent [candidate] (825.049 ms) : 0, 825049
GlobalTracer [baseline] (234.229 ms) : 0, 234229
GlobalTracer [candidate] (234.962 ms) : 0, 234962
IAST [baseline] (30.068 ms) : 0, 30068
IAST [candidate] (33.824 ms) : 0, 33824
AppSec [baseline] (31.839 ms) : 0, 31839
AppSec [candidate] (28.13 ms) : 0, 28130
Debugger [baseline] (6.102 ms) : 0, 6102
Debugger [candidate] (6.163 ms) : 0, 6163
Remote Config [baseline] (603.322 µs) : 0, 603
Remote Config [candidate] (598.312 µs) : 0, 598
Telemetry [baseline] (8.559 ms) : 0, 8559
Telemetry [candidate] (8.516 ms) : 0, 8516
Flare Poller [baseline] (4.177 ms) : 0, 4177
Flare Poller [candidate] (4.155 ms) : 0, 4155
LoadParameters
 See matching parameters
 SummaryFound 2 performance improvements and 3 performance regressions! Performance is the same for 7 metrics, 12 unstable metrics. 
 Request duration reports for insecure-bankgantt
    title insecure-bank - request duration [CI 0.99] : candidate=1.55.0-SNAPSHOT~29b3509c96, baseline=1.55.0-SNAPSHOT~f296927f57
    dateFormat X
    axisFormat %s
section baseline
no_agent (4.136 ms) : 4088, 4185
.   : milestone, 4136,
iast (9.339 ms) : 9179, 9499
.   : milestone, 9339,
iast_FULL (14.84 ms) : 14545, 15135
.   : milestone, 14840,
iast_GLOBAL (10.691 ms) : 10500, 10881
.   : milestone, 10691,
profiling (8.905 ms) : 8758, 9053
.   : milestone, 8905,
tracing (7.863 ms) : 7739, 7986
.   : milestone, 7863,
section candidate
no_agent (4.296 ms) : 4248, 4345
.   : milestone, 4296,
iast (9.949 ms) : 9780, 10118
.   : milestone, 9949,
iast_FULL (14.215 ms) : 13933, 14497
.   : milestone, 14215,
iast_GLOBAL (11.031 ms) : 10829, 11233
.   : milestone, 11031,
profiling (8.597 ms) : 8465, 8729
.   : milestone, 8597,
tracing (7.735 ms) : 7624, 7846
.   : milestone, 7735,
 
 
 
 Request duration reports for petclinicgantt
    title petclinic - request duration [CI 0.99] : candidate=1.55.0-SNAPSHOT~29b3509c96, baseline=1.55.0-SNAPSHOT~f296927f57
    dateFormat X
    axisFormat %s
section baseline
no_agent (37.47 ms) : 37163, 37778
.   : milestone, 37470,
appsec (47.055 ms) : 46639, 47471
.   : milestone, 47055,
code_origins (43.311 ms) : 42929, 43693
.   : milestone, 43311,
iast (43.851 ms) : 43489, 44214
.   : milestone, 43851,
profiling (47.357 ms) : 46935, 47779
.   : milestone, 47357,
tracing (43.459 ms) : 43098, 43821
.   : milestone, 43459,
section candidate
no_agent (36.164 ms) : 35874, 36453
.   : milestone, 36164,
appsec (47.744 ms) : 47334, 48154
.   : milestone, 47744,
code_origins (42.122 ms) : 41758, 42487
.   : milestone, 42122,
iast (43.941 ms) : 43572, 44310
.   : milestone, 43941,
profiling (48.453 ms) : 47997, 48910
.   : milestone, 48453,
tracing (44.783 ms) : 44411, 45155
.   : milestone, 44783,
 
 
 
 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.55.0-SNAPSHOT~29b3509c96, baseline=1.55.0-SNAPSHOT~f296927f57
    dateFormat X
    axisFormat %s
section baseline
no_agent (15.147 s) : 15147000, 15147000
.   : milestone, 15147000,
appsec (14.765 s) : 14765000, 14765000
.   : milestone, 14765000,
iast (18.7 s) : 18700000, 18700000
.   : milestone, 18700000,
iast_GLOBAL (18.126 s) : 18126000, 18126000
.   : milestone, 18126000,
profiling (15.028 s) : 15028000, 15028000
.   : milestone, 15028000,
tracing (14.98 s) : 14980000, 14980000
.   : milestone, 14980000,
section candidate
no_agent (15.446 s) : 15446000, 15446000
.   : milestone, 15446000,
appsec (15.011 s) : 15011000, 15011000
.   : milestone, 15011000,
iast (18.813 s) : 18813000, 18813000
.   : milestone, 18813000,
iast_GLOBAL (18.325 s) : 18325000, 18325000
.   : milestone, 18325000,
profiling (15.18 s) : 15180000, 15180000
.   : milestone, 15180000,
tracing (15.236 s) : 15236000, 15236000
.   : milestone, 15236000,
 
 
 
 Execution time for tomcatgantt
    title tomcat - execution time [CI 0.99] : candidate=1.55.0-SNAPSHOT~29b3509c96, baseline=1.55.0-SNAPSHOT~f296927f57
    dateFormat X
    axisFormat %s
section baseline
no_agent (1.482 ms) : 1471, 1494
.   : milestone, 1482,
appsec (3.725 ms) : 3501, 3949
.   : milestone, 3725,
iast (2.236 ms) : 2171, 2301
.   : milestone, 2236,
iast_GLOBAL (2.265 ms) : 2200, 2329
.   : milestone, 2265,
profiling (2.063 ms) : 2012, 2115
.   : milestone, 2063,
tracing (2.053 ms) : 2003, 2103
.   : milestone, 2053,
section candidate
no_agent (1.485 ms) : 1473, 1496
.   : milestone, 1485,
appsec (3.798 ms) : 3574, 4022
.   : milestone, 3798,
iast (2.223 ms) : 2159, 2288
.   : milestone, 2223,
iast_GLOBAL (2.279 ms) : 2214, 2344
.   : milestone, 2279,
profiling (2.476 ms) : 2318, 2634
.   : milestone, 2476,
tracing (2.043 ms) : 1993, 2094
.   : milestone, 2043,
 
 
 
 | 
d498d7c    to
    29b3509      
    Compare
  
    | private static MethodHandle findThreadIdMethodHandle() { | ||
| if (JavaVirtualMachine.isJavaVersionAtLeast(19)) { | ||
| try { | ||
| return MethodHandles.lookup() | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have this utility class datadog.trace.util.MethodHandles for dealing with method handles lookup that might be handy to use. It also logs in case of failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s interesting but it’s part of :internal-api so it won’t be accessible.
Additionally, do we expect to log (in telemetry) when we are not sure about the method availability? Here, we are trying to get it to check if the capability is available but it’s fine if it isn’t.
What Does This Do
This PR improves the environment component to be able to check for virtual threads support.
EDIT: Support was already added in #9537 then this PR only brings few additional elements compared to the original
ThreadUtils:threadId()with current threadnewVirtualThreadPerTaskExecutor()ExecutorServicesto allow its usage from coreJavaVirtualMachine.isJavaVersionAtLeast()instead ofJavaVersion.getRuntimeVersion().isAtLeast()to avoid parsing version number multiple timesThreadUtilsto theThreadSupportas there are already twoThreadUtilsclasses (datadog.trace.ThreadUtilsanddatadog.trace.agent.test.utils.ThreadUtils)Motivation
With the adoption of modern Java versions, we will need to check for virtual threads to avoid expensive per-thread work or memory allocation (like ThreadLocals).
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]