Reuse TagMap.Entry objects in InternalTagsAdder#10965
Conversation
Co-authored-by: dougqh <dougqh@gmail.com>
|
I can only run on private repositories. |
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 62 metrics, 9 unstable metrics. Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.61.0-SNAPSHOT~b295f57894, baseline=1.61.0-SNAPSHOT~a1239d32d8
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.056 s) : 0, 1056044
Total [baseline] (8.81 s) : 0, 8810245
Agent [candidate] (1.061 s) : 0, 1060904
Total [candidate] (8.863 s) : 0, 8863485
section iast
Agent [baseline] (1.228 s) : 0, 1228405
Total [baseline] (9.549 s) : 0, 9549467
Agent [candidate] (1.249 s) : 0, 1249285
Total [candidate] (9.62 s) : 0, 9620308
gantt
title insecure-bank - break down per module: candidate=1.61.0-SNAPSHOT~b295f57894, baseline=1.61.0-SNAPSHOT~a1239d32d8
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.198 ms) : 0, 1198
crashtracking [candidate] (1.205 ms) : 0, 1205
BytebuddyAgent [baseline] (628.955 ms) : 0, 628955
BytebuddyAgent [candidate] (630.303 ms) : 0, 630303
AgentMeter [baseline] (29.309 ms) : 0, 29309
AgentMeter [candidate] (29.403 ms) : 0, 29403
GlobalTracer [baseline] (256.519 ms) : 0, 256519
GlobalTracer [candidate] (257.687 ms) : 0, 257687
AppSec [baseline] (31.778 ms) : 0, 31778
AppSec [candidate] (31.829 ms) : 0, 31829
Debugger [baseline] (59.457 ms) : 0, 59457
Debugger [candidate] (59.825 ms) : 0, 59825
Remote Config [baseline] (588.269 µs) : 0, 588
Remote Config [candidate] (588.679 µs) : 0, 589
Telemetry [baseline] (8.026 ms) : 0, 8026
Telemetry [candidate] (8.085 ms) : 0, 8085
Flare Poller [baseline] (4.219 ms) : 0, 4219
Flare Poller [candidate] (5.769 ms) : 0, 5769
section iast
crashtracking [baseline] (1.186 ms) : 0, 1186
crashtracking [candidate] (1.246 ms) : 0, 1246
BytebuddyAgent [baseline] (797.565 ms) : 0, 797565
BytebuddyAgent [candidate] (812.466 ms) : 0, 812466
AgentMeter [baseline] (11.414 ms) : 0, 11414
AgentMeter [candidate] (11.764 ms) : 0, 11764
GlobalTracer [baseline] (247.733 ms) : 0, 247733
GlobalTracer [candidate] (250.369 ms) : 0, 250369
AppSec [baseline] (26.54 ms) : 0, 26540
AppSec [candidate] (26.961 ms) : 0, 26961
Debugger [baseline] (67.729 ms) : 0, 67729
Debugger [candidate] (70.933 ms) : 0, 70933
Remote Config [baseline] (520.757 µs) : 0, 521
Remote Config [candidate] (535.685 µs) : 0, 536
Telemetry [baseline] (10.64 ms) : 0, 10640
Telemetry [candidate] (9.283 ms) : 0, 9283
Flare Poller [baseline] (3.748 ms) : 0, 3748
Flare Poller [candidate] (3.443 ms) : 0, 3443
IAST [baseline] (25.385 ms) : 0, 25385
IAST [candidate] (25.682 ms) : 0, 25682
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.61.0-SNAPSHOT~b295f57894, baseline=1.61.0-SNAPSHOT~a1239d32d8
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.058 s) : 0, 1057770
Total [baseline] (11.036 s) : 0, 11036250
Agent [candidate] (1.08 s) : 0, 1080025
Total [candidate] (11.14 s) : 0, 11139973
section appsec
Agent [baseline] (1.246 s) : 0, 1246325
Total [baseline] (11.099 s) : 0, 11098881
Agent [candidate] (1.251 s) : 0, 1251252
Total [candidate] (11.165 s) : 0, 11164994
section iast
Agent [baseline] (1.231 s) : 0, 1231389
Total [baseline] (10.561 s) : 0, 10560638
Agent [candidate] (1.237 s) : 0, 1237235
Total [candidate] (11.336 s) : 0, 11335731
section profiling
Agent [baseline] (1.18 s) : 0, 1180068
Total [baseline] (11.017 s) : 0, 11017049
Agent [candidate] (1.188 s) : 0, 1188041
Total [candidate] (11.019 s) : 0, 11019035
gantt
title petclinic - break down per module: candidate=1.61.0-SNAPSHOT~b295f57894, baseline=1.61.0-SNAPSHOT~a1239d32d8
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.189 ms) : 0, 1189
crashtracking [candidate] (1.226 ms) : 0, 1226
BytebuddyAgent [baseline] (629.893 ms) : 0, 629893
BytebuddyAgent [candidate] (642.755 ms) : 0, 642755
AgentMeter [baseline] (29.399 ms) : 0, 29399
AgentMeter [candidate] (30.035 ms) : 0, 30035
GlobalTracer [baseline] (256.94 ms) : 0, 256940
GlobalTracer [candidate] (261.853 ms) : 0, 261853
AppSec [baseline] (31.849 ms) : 0, 31849
AppSec [candidate] (32.485 ms) : 0, 32485
Debugger [baseline] (60.347 ms) : 0, 60347
Debugger [candidate] (61.647 ms) : 0, 61647
Remote Config [baseline] (614.074 µs) : 0, 614
Remote Config [candidate] (598.892 µs) : 0, 599
Telemetry [baseline] (7.997 ms) : 0, 7997
Telemetry [candidate] (9.065 ms) : 0, 9065
Flare Poller [baseline] (3.539 ms) : 0, 3539
Flare Poller [candidate] (3.647 ms) : 0, 3647
section appsec
crashtracking [baseline] (1.183 ms) : 0, 1183
crashtracking [candidate] (1.192 ms) : 0, 1192
BytebuddyAgent [baseline] (658.906 ms) : 0, 658906
BytebuddyAgent [candidate] (660.85 ms) : 0, 660850
AgentMeter [baseline] (12.109 ms) : 0, 12109
AgentMeter [candidate] (12.215 ms) : 0, 12215
GlobalTracer [baseline] (257.531 ms) : 0, 257531
GlobalTracer [candidate] (258.932 ms) : 0, 258932
AppSec [baseline] (177.212 ms) : 0, 177212
AppSec [candidate] (177.928 ms) : 0, 177928
Debugger [baseline] (66.357 ms) : 0, 66357
Debugger [candidate] (66.827 ms) : 0, 66827
Remote Config [baseline] (632.556 µs) : 0, 633
Remote Config [candidate] (647.113 µs) : 0, 647
Telemetry [baseline] (8.48 ms) : 0, 8480
Telemetry [candidate] (8.347 ms) : 0, 8347
Flare Poller [baseline] (3.635 ms) : 0, 3635
Flare Poller [candidate] (3.618 ms) : 0, 3618
IAST [baseline] (24.134 ms) : 0, 24134
IAST [candidate] (24.246 ms) : 0, 24246
section iast
crashtracking [baseline] (1.174 ms) : 0, 1174
crashtracking [candidate] (1.192 ms) : 0, 1192
BytebuddyAgent [baseline] (799.401 ms) : 0, 799401
BytebuddyAgent [candidate] (802.573 ms) : 0, 802573
AgentMeter [baseline] (11.436 ms) : 0, 11436
AgentMeter [candidate] (11.485 ms) : 0, 11485
GlobalTracer [baseline] (248.024 ms) : 0, 248024
GlobalTracer [candidate] (248.916 ms) : 0, 248916
AppSec [baseline] (27.485 ms) : 0, 27485
AppSec [candidate] (26.695 ms) : 0, 26695
Debugger [baseline] (68.019 ms) : 0, 68019
Debugger [candidate] (70.404 ms) : 0, 70404
Remote Config [baseline] (520.281 µs) : 0, 520
Remote Config [candidate] (531.561 µs) : 0, 532
Telemetry [baseline] (10.262 ms) : 0, 10262
Telemetry [candidate] (10.006 ms) : 0, 10006
Flare Poller [baseline] (3.688 ms) : 0, 3688
Flare Poller [candidate] (3.56 ms) : 0, 3560
IAST [baseline] (25.348 ms) : 0, 25348
IAST [candidate] (25.515 ms) : 0, 25515
section profiling
ProfilingAgent [baseline] (93.489 ms) : 0, 93489
ProfilingAgent [candidate] (93.935 ms) : 0, 93935
crashtracking [baseline] (1.168 ms) : 0, 1168
crashtracking [candidate] (1.174 ms) : 0, 1174
BytebuddyAgent [baseline] (681.768 ms) : 0, 681768
BytebuddyAgent [candidate] (686.072 ms) : 0, 686072
AgentMeter [baseline] (8.928 ms) : 0, 8928
AgentMeter [candidate] (8.933 ms) : 0, 8933
GlobalTracer [baseline] (214.509 ms) : 0, 214509
GlobalTracer [candidate] (216.272 ms) : 0, 216272
AppSec [baseline] (32.163 ms) : 0, 32163
AppSec [candidate] (32.524 ms) : 0, 32524
Debugger [baseline] (65.724 ms) : 0, 65724
Debugger [candidate] (66.155 ms) : 0, 66155
Remote Config [baseline] (560.138 µs) : 0, 560
Remote Config [candidate] (567.052 µs) : 0, 567
Telemetry [baseline] (7.727 ms) : 0, 7727
Telemetry [candidate] (7.751 ms) : 0, 7751
Flare Poller [baseline] (3.467 ms) : 0, 3467
Flare Poller [candidate] (3.494 ms) : 0, 3494
Profiling [baseline] (94.041 ms) : 0, 94041
Profiling [candidate] (94.485 ms) : 0, 94485
LoadParameters
See matching parameters
SummaryFound 1 performance improvements and 3 performance regressions! Performance is the same for 15 metrics, 17 unstable metrics.
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.61.0-SNAPSHOT~b295f57894, baseline=1.61.0-SNAPSHOT~a1239d32d8
dateFormat X
axisFormat %s
section baseline
no_agent (18.306 ms) : 18116, 18496
. : milestone, 18306,
appsec (18.85 ms) : 18653, 19047
. : milestone, 18850,
code_origins (17.71 ms) : 17533, 17888
. : milestone, 17710,
iast (17.958 ms) : 17780, 18136
. : milestone, 17958,
profiling (18.537 ms) : 18354, 18720
. : milestone, 18537,
tracing (17.791 ms) : 17614, 17969
. : milestone, 17791,
section candidate
no_agent (19.364 ms) : 19166, 19563
. : milestone, 19364,
appsec (18.57 ms) : 18383, 18758
. : milestone, 18570,
code_origins (17.712 ms) : 17537, 17887
. : milestone, 17712,
iast (18.044 ms) : 17863, 18224
. : milestone, 18044,
profiling (18.983 ms) : 18798, 19169
. : milestone, 18983,
tracing (18.966 ms) : 18780, 19151
. : milestone, 18966,
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.61.0-SNAPSHOT~b295f57894, baseline=1.61.0-SNAPSHOT~a1239d32d8
dateFormat X
axisFormat %s
section baseline
no_agent (1.174 ms) : 1163, 1185
. : milestone, 1174,
iast (3.267 ms) : 3217, 3318
. : milestone, 3267,
iast_FULL (5.84 ms) : 5782, 5899
. : milestone, 5840,
iast_GLOBAL (3.503 ms) : 3447, 3559
. : milestone, 3503,
profiling (2.008 ms) : 1990, 2025
. : milestone, 2008,
tracing (1.816 ms) : 1801, 1830
. : milestone, 1816,
section candidate
no_agent (1.175 ms) : 1164, 1187
. : milestone, 1175,
iast (3.126 ms) : 3089, 3164
. : milestone, 3126,
iast_FULL (5.752 ms) : 5693, 5810
. : milestone, 5752,
iast_GLOBAL (3.721 ms) : 3658, 3785
. : milestone, 3721,
profiling (2.22 ms) : 2199, 2241
. : milestone, 2220,
tracing (1.796 ms) : 1781, 1811
. : milestone, 1796,
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 tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.61.0-SNAPSHOT~b295f57894, baseline=1.61.0-SNAPSHOT~a1239d32d8
dateFormat X
axisFormat %s
section baseline
no_agent (1.474 ms) : 1462, 1485
. : milestone, 1474,
appsec (2.534 ms) : 2478, 2590
. : milestone, 2534,
iast (2.264 ms) : 2194, 2333
. : milestone, 2264,
iast_GLOBAL (2.294 ms) : 2225, 2364
. : milestone, 2294,
profiling (2.114 ms) : 2058, 2170
. : milestone, 2114,
tracing (2.074 ms) : 2021, 2128
. : milestone, 2074,
section candidate
no_agent (1.477 ms) : 1465, 1488
. : milestone, 1477,
appsec (2.53 ms) : 2475, 2586
. : milestone, 2530,
iast (2.274 ms) : 2205, 2344
. : milestone, 2274,
iast_GLOBAL (2.298 ms) : 2228, 2368
. : milestone, 2298,
profiling (2.09 ms) : 2035, 2145
. : milestone, 2090,
tracing (2.066 ms) : 2012, 2119
. : milestone, 2066,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.61.0-SNAPSHOT~b295f57894, baseline=1.61.0-SNAPSHOT~a1239d32d8
dateFormat X
axisFormat %s
section baseline
no_agent (15.572 s) : 15572000, 15572000
. : milestone, 15572000,
appsec (15.139 s) : 15139000, 15139000
. : milestone, 15139000,
iast (18.442 s) : 18442000, 18442000
. : milestone, 18442000,
iast_GLOBAL (17.86 s) : 17860000, 17860000
. : milestone, 17860000,
profiling (14.856 s) : 14856000, 14856000
. : milestone, 14856000,
tracing (14.77 s) : 14770000, 14770000
. : milestone, 14770000,
section candidate
no_agent (15.503 s) : 15503000, 15503000
. : milestone, 15503000,
appsec (15.034 s) : 15034000, 15034000
. : milestone, 15034000,
iast (18.084 s) : 18084000, 18084000
. : milestone, 18084000,
iast_GLOBAL (18.093 s) : 18093000, 18093000
. : milestone, 18093000,
profiling (14.998 s) : 14998000, 14998000
. : milestone, 14998000,
tracing (14.679 s) : 14679000, 14679000
. : milestone, 14679000,
|
| if (!ddService.toString().equalsIgnoreCase(spanContext.getServiceName())) { | ||
| // service name != DD_SERVICE | ||
| unsafeTags.set(DDTags.BASE_SERVICE, ddService); | ||
| unsafeTags.set(ddServiceEntry); |
There was a problem hiding this comment.
if ddService == "", then TagMap.Entry.create returns ddServiceEntry == null, which will lead to an NPE here
There was a problem hiding this comment.
Good catch. I let AI generate this.
I had also made DDSpan ignore setTag / setMetric null.
But I didn't do the same for TagMap, and I don't think that I want to. I'll go back and check the null handling more carefully.
There was a problem hiding this comment.
I think I'm going to just get rid of the ddService member variable altogether. TagMap.Entry caches the result of stringValue, so that will be just as good for the equalsIgnoreCase check.
It still isn't clear to me what the original intention was in the case when ddService is the empty string. If I recall correctly, DDSpan / DDSpanContext treat setting empty string as request to the delete the associated tag.
However, I'm not sure that's the intended semantic here. It is also strange because version does have explicit empty handling.
|
From the review, I think it is clear that we need more tests for how null & empty are handled. I'm going to add those before merging this; however, I think I'm going to try to land #10822 first. That PR extensively reworks the tests, and the allocation reduction is bigger. |
What Does This Do
Pre-constructs
TagMap.Entryobjects forddServiceandversiontags in theInternalTagsAdderconstructor, then uses these pre-built entries directly when adding tags viaunsafeTags.set.Motivation
Optimizes tag processing by constructing
TagMap.Entryobjects once during initialization rather than constructing them on every span processing call. This reduces object allocation overhead and improves performance for high-throughput tracing scenarios.Additional Notes
ddServicefield type is changed fromUTF8BytesStringtoStringas the UTF8 conversion is now handled duringTagMap.EntryconstructionddServiceEntryandversionEntryare constructed conditionally based on null/empty checks in the constructorprocessTagsmethod now directly passes pre-constructed entries tounsafeTags.set()instead of constructing them inlineJira ticket: APMLP-1144
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issuePR by Bits - View session in Datadog
Comment @DataDog to request changes