-
Notifications
You must be signed in to change notification settings - Fork 320
Improves CSS peer tag aggregation #9336
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
Improves CSS peer tag aggregation #9336
Conversation
dd-trace-core/src/main/java/datadog/trace/common/metrics/ConflatingMetricsAggregator.java
Outdated
Show resolved
Hide resolved
|
Code coverage: total 57.16%, patch 100.00% (view details) This comment will be updated automatically if new data arrives.🔗 Commit SHA: 5c744a7 | Docs | Was this helpful? Give us feedback! |
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 45 metrics, 14 unstable metrics. Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.53.0-SNAPSHOT~5c744a7106, baseline=1.53.0-SNAPSHOT~0eeb9e597f
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.042 s) : 0, 1042436
Total [baseline] (8.579 s) : 0, 8578585
Agent [candidate] (1.045 s) : 0, 1044876
Total [candidate] (8.61 s) : 0, 8610311
section iast
Agent [baseline] (1.178 s) : 0, 1178409
Total [baseline] (9.313 s) : 0, 9312954
Agent [candidate] (1.192 s) : 0, 1191996
Total [candidate] (9.345 s) : 0, 9345352
gantt
title insecure-bank - break down per module: candidate=1.53.0-SNAPSHOT~5c744a7106, baseline=1.53.0-SNAPSHOT~0eeb9e597f
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.434 ms) : 0, 1434
crashtracking [candidate] (1.428 ms) : 0, 1428
BytebuddyAgent [baseline] (729.618 ms) : 0, 729618
BytebuddyAgent [candidate] (731.424 ms) : 0, 731424
GlobalTracer [baseline] (241.215 ms) : 0, 241215
GlobalTracer [candidate] (241.772 ms) : 0, 241772
AppSec [baseline] (29.95 ms) : 0, 29950
AppSec [candidate] (30.037 ms) : 0, 30037
Debugger [baseline] (5.975 ms) : 0, 5975
Debugger [candidate] (6.039 ms) : 0, 6039
Remote Config [baseline] (646.264 µs) : 0, 646
Remote Config [candidate] (648.805 µs) : 0, 649
Telemetry [baseline] (12.677 ms) : 0, 12677
Telemetry [candidate] (12.613 ms) : 0, 12613
section iast
crashtracking [baseline] (1.436 ms) : 0, 1436
crashtracking [candidate] (1.45 ms) : 0, 1450
BytebuddyAgent [baseline] (850.779 ms) : 0, 850779
BytebuddyAgent [candidate] (862.13 ms) : 0, 862130
GlobalTracer [baseline] (233.215 ms) : 0, 233215
GlobalTracer [candidate] (234.84 ms) : 0, 234840
IAST [baseline] (28.29 ms) : 0, 28290
IAST [candidate] (27.999 ms) : 0, 27999
AppSec [baseline] (29.139 ms) : 0, 29139
AppSec [candidate] (28.905 ms) : 0, 28905
Debugger [baseline] (5.721 ms) : 0, 5721
Debugger [candidate] (6.611 ms) : 0, 6611
Remote Config [baseline] (580.464 µs) : 0, 580
Remote Config [candidate] (606.523 µs) : 0, 607
Telemetry [baseline] (8.262 ms) : 0, 8262
Telemetry [candidate] (8.223 ms) : 0, 8223
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.53.0-SNAPSHOT~5c744a7106, baseline=1.53.0-SNAPSHOT~0eeb9e597f
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.045 s) : 0, 1044755
Total [baseline] (10.686 s) : 0, 10685524
Agent [candidate] (1.048 s) : 0, 1047558
Total [candidate] (10.635 s) : 0, 10635385
section appsec
Agent [baseline] (1.227 s) : 0, 1226696
Total [baseline] (10.808 s) : 0, 10807506
Agent [candidate] (1.226 s) : 0, 1225676
Total [candidate] (10.778 s) : 0, 10777642
section iast
Agent [baseline] (1.186 s) : 0, 1185816
Total [baseline] (10.964 s) : 0, 10963954
Agent [candidate] (1.174 s) : 0, 1173907
Total [candidate] (10.948 s) : 0, 10948003
section profiling
Agent [baseline] (1.194 s) : 0, 1193708
Total [baseline] (10.896 s) : 0, 10896483
Agent [candidate] (1.199 s) : 0, 1199089
Total [candidate] (10.858 s) : 0, 10858119
gantt
title petclinic - break down per module: candidate=1.53.0-SNAPSHOT~5c744a7106, baseline=1.53.0-SNAPSHOT~0eeb9e597f
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.427 ms) : 0, 1427
crashtracking [candidate] (1.462 ms) : 0, 1462
BytebuddyAgent [baseline] (731.224 ms) : 0, 731224
BytebuddyAgent [candidate] (735.101 ms) : 0, 735101
GlobalTracer [baseline] (241.691 ms) : 0, 241691
GlobalTracer [candidate] (242.936 ms) : 0, 242936
AppSec [baseline] (30.017 ms) : 0, 30017
AppSec [candidate] (30.258 ms) : 0, 30258
Debugger [baseline] (6.026 ms) : 0, 6026
Debugger [candidate] (6.054 ms) : 0, 6054
Remote Config [baseline] (647.786 µs) : 0, 648
Remote Config [candidate] (657.607 µs) : 0, 658
Telemetry [baseline] (12.661 ms) : 0, 12661
Telemetry [candidate] (9.291 ms) : 0, 9291
section appsec
crashtracking [baseline] (1.441 ms) : 0, 1441
crashtracking [candidate] (1.443 ms) : 0, 1443
BytebuddyAgent [baseline] (757.985 ms) : 0, 757985
BytebuddyAgent [candidate] (756.945 ms) : 0, 756945
GlobalTracer [baseline] (235.939 ms) : 0, 235939
GlobalTracer [candidate] (235.917 ms) : 0, 235917
AppSec [baseline] (167.98 ms) : 0, 167980
AppSec [candidate] (170.269 ms) : 0, 170269
Debugger [baseline] (7.925 ms) : 0, 7925
Debugger [candidate] (6.481 ms) : 0, 6481
Remote Config [baseline] (628.254 µs) : 0, 628
Remote Config [candidate] (652.955 µs) : 0, 653
Telemetry [baseline] (9.959 ms) : 0, 9959
Telemetry [candidate] (9.017 ms) : 0, 9017
IAST [baseline] (23.692 ms) : 0, 23692
IAST [candidate] (23.754 ms) : 0, 23754
section iast
crashtracking [baseline] (1.438 ms) : 0, 1438
crashtracking [candidate] (1.424 ms) : 0, 1424
BytebuddyAgent [baseline] (857.28 ms) : 0, 857280
BytebuddyAgent [candidate] (847.824 ms) : 0, 847824
GlobalTracer [baseline] (233.509 ms) : 0, 233509
GlobalTracer [candidate] (231.571 ms) : 0, 231571
AppSec [baseline] (26.986 ms) : 0, 26986
AppSec [candidate] (26.074 ms) : 0, 26074
Debugger [baseline] (8.24 ms) : 0, 8240
Debugger [candidate] (6.656 ms) : 0, 6656
Remote Config [baseline] (579.919 µs) : 0, 580
Remote Config [candidate] (587.528 µs) : 0, 588
Telemetry [baseline] (8.227 ms) : 0, 8227
Telemetry [candidate] (8.101 ms) : 0, 8101
IAST [baseline] (28.424 ms) : 0, 28424
IAST [candidate] (30.724 ms) : 0, 30724
section profiling
ProfilingAgent [baseline] (108.495 ms) : 0, 108495
ProfilingAgent [candidate] (108.131 ms) : 0, 108131
crashtracking [baseline] (1.403 ms) : 0, 1403
crashtracking [candidate] (1.404 ms) : 0, 1404
BytebuddyAgent [baseline] (760.32 ms) : 0, 760320
BytebuddyAgent [candidate] (764.413 ms) : 0, 764413
GlobalTracer [baseline] (221.602 ms) : 0, 221602
GlobalTracer [candidate] (222.275 ms) : 0, 222275
AppSec [baseline] (30.039 ms) : 0, 30039
AppSec [candidate] (30.059 ms) : 0, 30059
Debugger [baseline] (6.276 ms) : 0, 6276
Debugger [candidate] (6.344 ms) : 0, 6344
Remote Config [baseline] (675.147 µs) : 0, 675
Remote Config [candidate] (698.407 µs) : 0, 698
Telemetry [baseline] (15.275 ms) : 0, 15275
Telemetry [candidate] (16.009 ms) : 0, 16009
Profiling [baseline] (109.135 ms) : 0, 109135
Profiling [candidate] (108.768 ms) : 0, 108768
LoadParameters
See matching parameters
SummaryFound 1 performance improvements and 0 performance regressions! Performance is the same for 11 metrics, 12 unstable metrics.
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.53.0-SNAPSHOT~5c744a7106, baseline=1.53.0-SNAPSHOT~0eeb9e597f
dateFormat X
axisFormat %s
section baseline
no_agent (4.404 ms) : 4350, 4458
. : milestone, 4404,
iast (9.333 ms) : 9177, 9488
. : milestone, 9333,
iast_FULL (13.866 ms) : 13592, 14139
. : milestone, 13866,
iast_GLOBAL (10.19 ms) : 10012, 10368
. : milestone, 10190,
profiling (8.737 ms) : 8593, 8880
. : milestone, 8737,
tracing (7.445 ms) : 7341, 7549
. : milestone, 7445,
section candidate
no_agent (4.268 ms) : 4220, 4317
. : milestone, 4268,
iast (9.255 ms) : 9103, 9407
. : milestone, 9255,
iast_FULL (14.073 ms) : 13789, 14357
. : milestone, 14073,
iast_GLOBAL (10.027 ms) : 9852, 10201
. : milestone, 10027,
profiling (8.617 ms) : 8473, 8762
. : milestone, 8617,
tracing (7.302 ms) : 7201, 7402
. : milestone, 7302,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.53.0-SNAPSHOT~5c744a7106, baseline=1.53.0-SNAPSHOT~0eeb9e597f
dateFormat X
axisFormat %s
section baseline
no_agent (36.783 ms) : 36484, 37082
. : milestone, 36783,
appsec (48.455 ms) : 48033, 48877
. : milestone, 48455,
code_origins (45.361 ms) : 44972, 45749
. : milestone, 45361,
iast (45.114 ms) : 44717, 45511
. : milestone, 45114,
profiling (50.042 ms) : 49519, 50566
. : milestone, 50042,
tracing (44.435 ms) : 44052, 44819
. : milestone, 44435,
section candidate
no_agent (36.823 ms) : 36528, 37118
. : milestone, 36823,
appsec (49.199 ms) : 48755, 49643
. : milestone, 49199,
code_origins (44.957 ms) : 44547, 45367
. : milestone, 44957,
iast (44.524 ms) : 44148, 44900
. : milestone, 44524,
profiling (49.945 ms) : 49509, 50380
. : milestone, 49945,
tracing (43.119 ms) : 42747, 43491
. : milestone, 43119,
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.53.0-SNAPSHOT~5c744a7106, baseline=1.53.0-SNAPSHOT~0eeb9e597f
dateFormat X
axisFormat %s
section baseline
no_agent (1.48 ms) : 1468, 1491
. : milestone, 1480,
appsec (3.671 ms) : 3454, 3888
. : milestone, 3671,
iast (2.204 ms) : 2141, 2267
. : milestone, 2204,
iast_GLOBAL (2.256 ms) : 2193, 2320
. : milestone, 2256,
profiling (2.058 ms) : 2007, 2108
. : milestone, 2058,
tracing (2.021 ms) : 1972, 2070
. : milestone, 2021,
section candidate
no_agent (1.481 ms) : 1469, 1492
. : milestone, 1481,
appsec (3.679 ms) : 3463, 3896
. : milestone, 3679,
iast (2.21 ms) : 2148, 2273
. : milestone, 2210,
iast_GLOBAL (2.25 ms) : 2187, 2313
. : milestone, 2250,
profiling (2.064 ms) : 2012, 2116
. : milestone, 2064,
tracing (2.027 ms) : 1979, 2076
. : milestone, 2027,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.53.0-SNAPSHOT~5c744a7106, baseline=1.53.0-SNAPSHOT~0eeb9e597f
dateFormat X
axisFormat %s
section baseline
no_agent (15.101 s) : 15101000, 15101000
. : milestone, 15101000,
appsec (14.99 s) : 14990000, 14990000
. : milestone, 14990000,
iast (18.518 s) : 18518000, 18518000
. : milestone, 18518000,
iast_GLOBAL (18.045 s) : 18045000, 18045000
. : milestone, 18045000,
profiling (15.817 s) : 15817000, 15817000
. : milestone, 15817000,
tracing (14.881 s) : 14881000, 14881000
. : milestone, 14881000,
section candidate
no_agent (15.399 s) : 15399000, 15399000
. : milestone, 15399000,
appsec (14.967 s) : 14967000, 14967000
. : milestone, 14967000,
iast (18.242 s) : 18242000, 18242000
. : milestone, 18242000,
iast_GLOBAL (17.956 s) : 17956000, 17956000
. : milestone, 17956000,
profiling (15.344 s) : 15344000, 15344000
. : milestone, 15344000,
tracing (15.101 s) : 15101000, 15101000
. : milestone, 15101000,
|
117434d to
09f0a12
Compare
| PEER_TAGS_CACHE_ADDER = | ||
| key -> | ||
| Pair.of( | ||
| DDCaches.newFixedSizeCache(512), |
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.
suggestion: Avoid magic values.
| String, Pair<DDCache<String, UTF8BytesString>, Function<String, UTF8BytesString>>> | ||
| PEER_TAGS_CACHE = | ||
| DDCaches.newUnboundedCache( | ||
| 64); // it can be unbounded since those values are returned by the agent and should be |
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.
suggestion: Make this a const, so maybe google java format will make the code readable.
| final Pair<DDCache<String, UTF8BytesString>, Function<String, UTF8BytesString>> pair = | ||
| PEER_TAGS_CACHE.computeIfAbsent(peerTag, PEER_TAGS_CACHE_ADDER); |
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.
suggestion: I suggest intermediate renaming to make this more legible.
09f0a12 to
e5b8954
Compare
e5b8954 to
5c744a7
Compare
f1139d7
into
bdu/add-missing-attributes-in-metrics-key
* Add jmh for metrics aggregation * Cache peer tags to avoid too many strings/utf8 conversions * Use span kind cache * Fix tests
* Add jmh for metrics aggregation * Cache peer tags to avoid too many strings/utf8 conversions * Use span kind cache * Fix tests
* Add jmh for metrics aggregation * Cache peer tags to avoid too many strings/utf8 conversions * Use span kind cache * Fix tests
* chore(css): Add peer tags, span kind and trace root flag to MetricKey bucket * chore(css): Use a map to create the metric key Also delays the creation of the Utf8ByteString at serialization time. Note that `writer.writeUTF8` emits a header corresponding to the length of the value being written, calling this method again will count as an entry in the array. A possible idea was to use a cache to store the computation of the peerTags, however `Utf8ByteString` is not concatenable / appendable, which is necessary to have the proper encoding. Creating a new "temporary" `Utf8ByteString`, was replaced by a direct call to `String: :getBytes`. * Improves CSS peer tag aggregation (#9336) * Add jmh for metrics aggregation * Cache peer tags to avoid too many strings/utf8 conversions * Use span kind cache * Fix tests * Hardcode eligible span kind since agent backpropagated are deprecated * revisit peer tags aggregation rules according to the rfc * IsTraceRoot is a tristate * Don't confuse trace root with top levels * Fix build after rebase --------- Co-authored-by: Andrea Marziali <[email protected]>
What Does This Do
Improves CSS serializer performances by caching peer tags creations (avoids also utf8 conversions)
The cache has been choosen big enough to contains high cardinality tag values like (peer.hostname). -> tested with org2
A JMH test shows that in case of cache hit (obviously) performs better (see below).
The peer tags cache is unbounded since those tags have low cardinality (they are fixed and returned by the agent).
Motivation
Additional Notes
Contributor Checklist
type:and (comp:orinst:) labels in addition to any usefull labelsclose,fixor any linking keywords when referencing an issue.Use
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]