-
Notifications
You must be signed in to change notification settings - Fork 293
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
Overhead improvement to agent feedback based sampling #8265
Overhead improvement to agent feedback based sampling #8265
Conversation
Previously, I updated this code to be case-insensitive. In doing so, I introduced a call to String.toLowerCase which had a negative impact on response time and allocation. By switching to TreeMap, I can use String::compareToIgnoreCase which avoids the allocation and has a better average complexity than toLowerCase. This change provides a 1-1.5% improvement in a span creation throughput stress tests.
Hi! 👋 Thanks for your pull request! 🎉 To help us review it, please make sure to:
If you need help, please check our contributing guidelines. |
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.
Good catch
dd-trace-core/src/main/java/datadog/trace/common/sampling/RateByServiceTraceSampler.java
Outdated
Show resolved
Hide resolved
dd-trace-core/src/main/java/datadog/trace/common/sampling/RateByServiceTraceSampler.java
Outdated
Show resolved
Hide resolved
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 59 metrics, 4 unstable metrics. Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.46.0-SNAPSHOT~73419906f3, baseline=1.46.0-SNAPSHOT~c58164b25d
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.037 s) : 0, 1036680
Total [baseline] (10.43 s) : 0, 10430277
Agent [candidate] (1.037 s) : 0, 1036780
Total [candidate] (10.475 s) : 0, 10475054
section appsec
Agent [baseline] (1.186 s) : 0, 1185587
Total [baseline] (10.803 s) : 0, 10802784
Agent [candidate] (1.185 s) : 0, 1184645
Total [candidate] (10.774 s) : 0, 10773878
section iast
Agent [baseline] (1.168 s) : 0, 1167790
Total [baseline] (10.944 s) : 0, 10944350
Agent [candidate] (1.169 s) : 0, 1168507
Total [candidate] (10.988 s) : 0, 10987800
section profiling
Agent [baseline] (1.255 s) : 0, 1254589
Total [baseline] (10.844 s) : 0, 10843818
Agent [candidate] (1.257 s) : 0, 1257284
Total [candidate] (10.799 s) : 0, 10799029
gantt
title petclinic - break down per module: candidate=1.46.0-SNAPSHOT~73419906f3, baseline=1.46.0-SNAPSHOT~c58164b25d
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (714.675 ms) : 0, 714675
BytebuddyAgent [candidate] (713.945 ms) : 0, 713945
GlobalTracer [baseline] (238.722 ms) : 0, 238722
GlobalTracer [candidate] (238.829 ms) : 0, 238829
AppSec [baseline] (55.786 ms) : 0, 55786
AppSec [candidate] (54.938 ms) : 0, 54938
Remote Config [baseline] (726.997 µs) : 0, 727
Remote Config [candidate] (712.462 µs) : 0, 712
Telemetry [baseline] (11.52 ms) : 0, 11520
Telemetry [candidate] (13.11 ms) : 0, 13110
section appsec
BytebuddyAgent [baseline] (736.247 ms) : 0, 736247
BytebuddyAgent [candidate] (736.418 ms) : 0, 736418
GlobalTracer [baseline] (237.478 ms) : 0, 237478
GlobalTracer [candidate] (236.799 ms) : 0, 236799
AppSec [baseline] (177.539 ms) : 0, 177539
AppSec [candidate] (176.618 ms) : 0, 176618
Remote Config [baseline] (676.327 µs) : 0, 676
Remote Config [candidate] (673.821 µs) : 0, 674
Telemetry [baseline] (8.567 ms) : 0, 8567
Telemetry [candidate] (8.986 ms) : 0, 8986
IAST [baseline] (19.489 ms) : 0, 19489
IAST [candidate] (19.506 ms) : 0, 19506
section iast
BytebuddyAgent [baseline] (833.7 ms) : 0, 833700
BytebuddyAgent [candidate] (834.007 ms) : 0, 834007
GlobalTracer [baseline] (230.176 ms) : 0, 230176
GlobalTracer [candidate] (229.851 ms) : 0, 229851
AppSec [baseline] (57.988 ms) : 0, 57988
AppSec [candidate] (58.283 ms) : 0, 58283
Remote Config [baseline] (647.953 µs) : 0, 648
Remote Config [candidate] (667.271 µs) : 0, 667
Telemetry [baseline] (8.668 ms) : 0, 8668
Telemetry [candidate] (8.758 ms) : 0, 8758
IAST [baseline] (21.296 ms) : 0, 21296
IAST [candidate] (21.594 ms) : 0, 21594
section profiling
ProfilingAgent [baseline] (95.26 ms) : 0, 95260
ProfilingAgent [candidate] (95.702 ms) : 0, 95702
BytebuddyAgent [baseline] (704.098 ms) : 0, 704098
BytebuddyAgent [candidate] (706.582 ms) : 0, 706582
GlobalTracer [baseline] (348.572 ms) : 0, 348572
GlobalTracer [candidate] (348.795 ms) : 0, 348795
AppSec [baseline] (54.936 ms) : 0, 54936
AppSec [candidate] (54.039 ms) : 0, 54039
Remote Config [baseline] (711.391 µs) : 0, 711
Remote Config [candidate] (732.838 µs) : 0, 733
Telemetry [baseline] (8.827 ms) : 0, 8827
Telemetry [candidate] (8.896 ms) : 0, 8896
Profiling [baseline] (95.285 ms) : 0, 95285
Profiling [candidate] (95.726 ms) : 0, 95726
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.46.0-SNAPSHOT~73419906f3, baseline=1.46.0-SNAPSHOT~c58164b25d
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.038 s) : 0, 1038249
Total [baseline] (8.654 s) : 0, 8654247
Agent [candidate] (1.041 s) : 0, 1040781
Total [candidate] (8.649 s) : 0, 8649231
section iast
Agent [baseline] (1.17 s) : 0, 1170112
Total [baseline] (9.204 s) : 0, 9203748
Agent [candidate] (1.167 s) : 0, 1167147
Total [candidate] (9.229 s) : 0, 9228590
section iast_HARDCODED_SECRET_DISABLED
Agent [baseline] (1.166 s) : 0, 1165599
Total [baseline] (9.18 s) : 0, 9180096
Agent [candidate] (1.166 s) : 0, 1166157
Total [candidate] (9.166 s) : 0, 9165736
section iast_TELEMETRY_OFF
Agent [baseline] (1.16 s) : 0, 1160260
Total [baseline] (9.212 s) : 0, 9211609
Agent [candidate] (1.163 s) : 0, 1163257
Total [candidate] (9.222 s) : 0, 9221596
gantt
title insecure-bank - break down per module: candidate=1.46.0-SNAPSHOT~73419906f3, baseline=1.46.0-SNAPSHOT~c58164b25d
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (714.751 ms) : 0, 714751
BytebuddyAgent [candidate] (715.165 ms) : 0, 715165
GlobalTracer [baseline] (238.918 ms) : 0, 238918
GlobalTracer [candidate] (239.467 ms) : 0, 239467
AppSec [baseline] (54.943 ms) : 0, 54943
AppSec [candidate] (55.855 ms) : 0, 55855
Remote Config [baseline] (704.218 µs) : 0, 704
Remote Config [candidate] (718.702 µs) : 0, 719
Telemetry [baseline] (13.718 ms) : 0, 13718
Telemetry [candidate] (14.28 ms) : 0, 14280
section iast
BytebuddyAgent [baseline] (836.599 ms) : 0, 836599
BytebuddyAgent [candidate] (833.411 ms) : 0, 833411
GlobalTracer [baseline] (228.99 ms) : 0, 228990
GlobalTracer [candidate] (229.336 ms) : 0, 229336
AppSec [baseline] (58.394 ms) : 0, 58394
AppSec [candidate] (58.13 ms) : 0, 58130
IAST [baseline] (21.391 ms) : 0, 21391
IAST [candidate] (21.501 ms) : 0, 21501
Remote Config [baseline] (652.549 µs) : 0, 653
Remote Config [candidate] (658.542 µs) : 0, 659
Telemetry [baseline] (8.746 ms) : 0, 8746
Telemetry [candidate] (8.746 ms) : 0, 8746
section iast_HARDCODED_SECRET_DISABLED
BytebuddyAgent [baseline] (832.721 ms) : 0, 832721
BytebuddyAgent [candidate] (832.558 ms) : 0, 832558
GlobalTracer [baseline] (228.703 ms) : 0, 228703
GlobalTracer [candidate] (229.186 ms) : 0, 229186
AppSec [baseline] (58.333 ms) : 0, 58333
AppSec [candidate] (58.314 ms) : 0, 58314
IAST [baseline] (21.178 ms) : 0, 21178
IAST [candidate] (21.368 ms) : 0, 21368
Remote Config [baseline] (652.377 µs) : 0, 652
Remote Config [candidate] (661.765 µs) : 0, 662
Telemetry [baseline] (8.725 ms) : 0, 8725
Telemetry [candidate] (8.775 ms) : 0, 8775
section iast_TELEMETRY_OFF
BytebuddyAgent [baseline] (827.725 ms) : 0, 827725
BytebuddyAgent [candidate] (830.117 ms) : 0, 830117
GlobalTracer [baseline] (228.55 ms) : 0, 228550
GlobalTracer [candidate] (229.356 ms) : 0, 229356
AppSec [baseline] (58.375 ms) : 0, 58375
AppSec [candidate] (58.224 ms) : 0, 58224
IAST [baseline] (21.052 ms) : 0, 21052
IAST [candidate] (20.968 ms) : 0, 20968
Remote Config [baseline] (667.017 µs) : 0, 667
Remote Config [candidate] (649.895 µs) : 0, 650
Telemetry [baseline] (8.624 ms) : 0, 8624
Telemetry [candidate] (8.676 ms) : 0, 8676
LoadParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 11 metrics, 17 unstable metrics. Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.46.0-SNAPSHOT~73419906f3, baseline=1.46.0-SNAPSHOT~c58164b25d
dateFormat X
axisFormat %s
section baseline
no_agent (372.862 µs) : 353, 392
. : milestone, 373,
iast (502.836 µs) : 480, 526
. : milestone, 503,
iast_FULL (737.344 µs) : 716, 759
. : milestone, 737,
iast_GLOBAL (548.472 µs) : 525, 572
. : milestone, 548,
iast_HARDCODED_SECRET_DISABLED (504.275 µs) : 481, 527
. : milestone, 504,
iast_INACTIVE (456.598 µs) : 435, 478
. : milestone, 457,
iast_TELEMETRY_OFF (495.098 µs) : 472, 518
. : milestone, 495,
tracing (451.719 µs) : 430, 473
. : milestone, 452,
section candidate
no_agent (372.912 µs) : 353, 393
. : milestone, 373,
iast (506.121 µs) : 482, 530
. : milestone, 506,
iast_FULL (737.873 µs) : 715, 761
. : milestone, 738,
iast_GLOBAL (550.367 µs) : 528, 573
. : milestone, 550,
iast_HARDCODED_SECRET_DISABLED (506.022 µs) : 483, 530
. : milestone, 506,
iast_INACTIVE (454.698 µs) : 434, 476
. : milestone, 455,
iast_TELEMETRY_OFF (490.233 µs) : 469, 512
. : milestone, 490,
tracing (448.78 µs) : 428, 470
. : milestone, 449,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.46.0-SNAPSHOT~73419906f3, baseline=1.46.0-SNAPSHOT~c58164b25d
dateFormat X
axisFormat %s
section baseline
no_agent (1.353 ms) : 1333, 1373
. : milestone, 1353,
appsec (1.74 ms) : 1716, 1764
. : milestone, 1740,
appsec_no_iast (1.75 ms) : 1728, 1772
. : milestone, 1750,
iast (1.495 ms) : 1470, 1520
. : milestone, 1495,
profiling (1.527 ms) : 1503, 1552
. : milestone, 1527,
tracing (1.484 ms) : 1459, 1509
. : milestone, 1484,
section candidate
no_agent (1.35 ms) : 1330, 1371
. : milestone, 1350,
appsec (1.733 ms) : 1710, 1757
. : milestone, 1733,
appsec_no_iast (1.745 ms) : 1722, 1768
. : milestone, 1745,
iast (1.498 ms) : 1473, 1522
. : milestone, 1498,
profiling (1.543 ms) : 1519, 1567
. : milestone, 1543,
tracing (1.505 ms) : 1481, 1530
. : milestone, 1505,
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 biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.46.0-SNAPSHOT~73419906f3, baseline=1.46.0-SNAPSHOT~c58164b25d
dateFormat X
axisFormat %s
section baseline
no_agent (15.253 s) : 15253000, 15253000
. : milestone, 15253000,
appsec (14.964 s) : 14964000, 14964000
. : milestone, 14964000,
iast (18.821 s) : 18821000, 18821000
. : milestone, 18821000,
iast_GLOBAL (18.137 s) : 18137000, 18137000
. : milestone, 18137000,
profiling (14.966 s) : 14966000, 14966000
. : milestone, 14966000,
tracing (15.191 s) : 15191000, 15191000
. : milestone, 15191000,
section candidate
no_agent (15.341 s) : 15341000, 15341000
. : milestone, 15341000,
appsec (15.207 s) : 15207000, 15207000
. : milestone, 15207000,
iast (18.415 s) : 18415000, 18415000
. : milestone, 18415000,
iast_GLOBAL (18.051 s) : 18051000, 18051000
. : milestone, 18051000,
profiling (14.913 s) : 14913000, 14913000
. : milestone, 14913000,
tracing (15.344 s) : 15344000, 15344000
. : milestone, 15344000,
Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.46.0-SNAPSHOT~73419906f3, baseline=1.46.0-SNAPSHOT~c58164b25d
dateFormat X
axisFormat %s
section baseline
no_agent (1.473 ms) : 1461, 1484
. : milestone, 1473,
appsec (2.36 ms) : 2317, 2403
. : milestone, 2360,
iast (2.113 ms) : 2058, 2167
. : milestone, 2113,
iast_GLOBAL (2.158 ms) : 2103, 2213
. : milestone, 2158,
profiling (2.461 ms) : 2273, 2648
. : milestone, 2461,
tracing (1.941 ms) : 1899, 1983
. : milestone, 1941,
section candidate
no_agent (1.471 ms) : 1460, 1483
. : milestone, 1471,
appsec (2.362 ms) : 2319, 2405
. : milestone, 2362,
iast (2.1 ms) : 2045, 2154
. : milestone, 2100,
iast_GLOBAL (2.151 ms) : 2096, 2206
. : milestone, 2151,
profiling (1.989 ms) : 1945, 2034
. : milestone, 1989,
tracing (1.946 ms) : 1903, 1988
. : milestone, 1946,
|
What Does This Do
Previously, I updated this code to be case-insensitive. In doing so, I introduced a call to String.toLowerCase which had a negative impact on response time and allocation.
By switching to TreeMap, I was able to use String::compareToIgnoreCase which avoids the allocation and has a better average complexity than String::toLowerCase.
Motivation
This change provides a 1-1.5% improvement in span creation throughput stress tests.