Avoid creating new ContinuingScope if the top scope is already keeping the span alive#5739
Merged
Merged
Conversation
mcculls
force-pushed
the
mcculls/reduce-scope-allocations
branch
2 times, most recently
from
August 18, 2023 13:11
4c25425 to
c08c8fc
Compare
mcculls
force-pushed
the
mcculls/reduce-scope-allocations
branch
from
August 18, 2023 13:26
c08c8fc to
5599c5a
Compare
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 62 cases. Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.20.0-SNAPSHOT~5599c5a44e, baseline=1.20.0-SNAPSHOT~4663dd598c
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (991.377 ms) : 0, 991377
Total [baseline] (9.18 s) : 0, 9180274
Agent [candidate] (985.205 ms) : 0, 985205
Total [candidate] (9.119 s) : 0, 9118919
section appsec
Agent [baseline] (1.069 s) : 0, 1069471
Total [baseline] (9.26 s) : 0, 9260172
Agent [candidate] (1.07 s) : 0, 1070492
Total [candidate] (9.216 s) : 0, 9215598
section iast
Agent [baseline] (1.088 s) : 0, 1087633
Total [baseline] (9.39 s) : 0, 9389931
Agent [candidate] (1.097 s) : 0, 1097021
Total [candidate] (9.559 s) : 0, 9559279
section profiling
Agent [baseline] (1.156 s) : 0, 1155817
Total [baseline] (9.474 s) : 0, 9473902
Agent [candidate] (1.157 s) : 0, 1157186
Total [candidate] (9.409 s) : 0, 9409227
gantt
title petclinic - break down per module: candidate=1.20.0-SNAPSHOT~5599c5a44e, baseline=1.20.0-SNAPSHOT~4663dd598c
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (614.546 ms) : 0, 614546
BytebuddyAgent [candidate] (610.312 ms) : 0, 610312
GlobalTracer [baseline] (285.2 ms) : 0, 285200
GlobalTracer [candidate] (283.738 ms) : 0, 283738
AppSec [baseline] (50.475 ms) : 0, 50475
AppSec [candidate] (50.304 ms) : 0, 50304
Remote Config [baseline] (660.927 µs) : 0, 661
Remote Config [candidate] (653.388 µs) : 0, 653
Telemetry [baseline] (6.055 ms) : 0, 6055
Telemetry [candidate] (5.992 ms) : 0, 5992
section appsec
BytebuddyAgent [baseline] (610.221 ms) : 0, 610221
BytebuddyAgent [candidate] (610.92 ms) : 0, 610920
GlobalTracer [baseline] (283.099 ms) : 0, 283099
GlobalTracer [candidate] (283.851 ms) : 0, 283851
AppSec [baseline] (135.361 ms) : 0, 135361
AppSec [candidate] (135.122 ms) : 0, 135122
Remote Config [baseline] (765.694 µs) : 0, 766
Remote Config [candidate] (724.165 µs) : 0, 724
Telemetry [baseline] (5.729 ms) : 0, 5729
Telemetry [candidate] (5.694 ms) : 0, 5694
section iast
BytebuddyAgent [baseline] (715.72 ms) : 0, 715720
BytebuddyAgent [candidate] (722.29 ms) : 0, 722290
GlobalTracer [baseline] (270.386 ms) : 0, 270386
GlobalTracer [candidate] (272.691 ms) : 0, 272691
AppSec [baseline] (46.922 ms) : 0, 46922
AppSec [candidate] (47.021 ms) : 0, 47021
Remote Config [baseline] (559.092 µs) : 0, 559
Remote Config [candidate] (560.361 µs) : 0, 560
Telemetry [baseline] (5.845 ms) : 0, 5845
Telemetry [candidate] (5.845 ms) : 0, 5845
IAST [baseline] (13.901 ms) : 0, 13901
IAST [candidate] (14.015 ms) : 0, 14015
section profiling
BytebuddyAgent [baseline] (622.521 ms) : 0, 622521
BytebuddyAgent [candidate] (623.176 ms) : 0, 623176
GlobalTracer [baseline] (348.503 ms) : 0, 348503
GlobalTracer [candidate] (348.955 ms) : 0, 348955
AppSec [baseline] (49.313 ms) : 0, 49313
AppSec [candidate] (48.963 ms) : 0, 48963
Remote Config [baseline] (660.829 µs) : 0, 661
Remote Config [candidate] (654.596 µs) : 0, 655
Telemetry [baseline] (5.998 ms) : 0, 5998
Telemetry [candidate] (5.919 ms) : 0, 5919
ProfilingAgent [baseline] (76.033 ms) : 0, 76033
ProfilingAgent [candidate] (76.638 ms) : 0, 76638
Profiling [baseline] (76.057 ms) : 0, 76057
Profiling [candidate] (76.662 ms) : 0, 76662
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.20.0-SNAPSHOT~5599c5a44e, baseline=1.20.0-SNAPSHOT~4663dd598c
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (991.533 ms) : 0, 991533
Total [baseline] (8.625 s) : 0, 8625016
Agent [candidate] (984.023 ms) : 0, 984023
Total [candidate] (8.604 s) : 0, 8604359
section appsec
Agent [baseline] (1.069 s) : 0, 1069342
Total [baseline] (8.687 s) : 0, 8686660
Agent [candidate] (1.07 s) : 0, 1070158
Total [candidate] (8.688 s) : 0, 8687534
section iast
Agent [baseline] (1.086 s) : 0, 1086330
Total [baseline] (9.112 s) : 0, 9111862
Agent [candidate] (1.089 s) : 0, 1088516
Total [candidate] (9.123 s) : 0, 9122555
section profiling
Agent [baseline] (1.155 s) : 0, 1155380
Total [baseline] (8.868 s) : 0, 8867745
Agent [candidate] (1.155 s) : 0, 1155042
Total [candidate] (8.861 s) : 0, 8860573
gantt
title insecure-bank - break down per module: candidate=1.20.0-SNAPSHOT~5599c5a44e, baseline=1.20.0-SNAPSHOT~4663dd598c
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (614.267 ms) : 0, 614267
BytebuddyAgent [candidate] (609.424 ms) : 0, 609424
GlobalTracer [baseline] (285.617 ms) : 0, 285617
GlobalTracer [candidate] (283.439 ms) : 0, 283439
AppSec [baseline] (50.405 ms) : 0, 50405
AppSec [candidate] (50.273 ms) : 0, 50273
Remote Config [baseline] (667.721 µs) : 0, 668
Remote Config [candidate] (654.136 µs) : 0, 654
Telemetry [baseline] (6.029 ms) : 0, 6029
Telemetry [candidate] (5.957 ms) : 0, 5957
section appsec
BytebuddyAgent [baseline] (610.125 ms) : 0, 610125
BytebuddyAgent [candidate] (610.338 ms) : 0, 610338
GlobalTracer [baseline] (283.498 ms) : 0, 283498
GlobalTracer [candidate] (283.618 ms) : 0, 283618
AppSec [baseline] (135.11 ms) : 0, 135110
AppSec [candidate] (135.485 ms) : 0, 135485
Remote Config [baseline] (722.113 µs) : 0, 722
Remote Config [candidate] (717.963 µs) : 0, 718
Telemetry [baseline] (5.697 ms) : 0, 5697
Telemetry [candidate] (5.705 ms) : 0, 5705
section iast
BytebuddyAgent [baseline] (715.246 ms) : 0, 715246
BytebuddyAgent [candidate] (716.641 ms) : 0, 716641
GlobalTracer [baseline] (269.953 ms) : 0, 269953
GlobalTracer [candidate] (270.384 ms) : 0, 270384
AppSec [baseline] (46.873 ms) : 0, 46873
AppSec [candidate] (47.104 ms) : 0, 47104
Remote Config [baseline] (546.658 µs) : 0, 547
Remote Config [candidate] (549.739 µs) : 0, 550
Telemetry [baseline] (5.734 ms) : 0, 5734
Telemetry [candidate] (5.744 ms) : 0, 5744
IAST [baseline] (13.759 ms) : 0, 13759
IAST [candidate] (13.887 ms) : 0, 13887
section profiling
BytebuddyAgent [baseline] (623.007 ms) : 0, 623007
BytebuddyAgent [candidate] (622.581 ms) : 0, 622581
GlobalTracer [baseline] (348.41 ms) : 0, 348410
GlobalTracer [candidate] (348.19 ms) : 0, 348190
AppSec [baseline] (49.28 ms) : 0, 49280
AppSec [candidate] (49.008 ms) : 0, 49008
Remote Config [baseline] (664.57 µs) : 0, 665
Remote Config [candidate] (653.168 µs) : 0, 653
Telemetry [baseline] (5.931 ms) : 0, 5931
Telemetry [candidate] (5.873 ms) : 0, 5873
ProfilingAgent [baseline] (75.163 ms) : 0, 75163
ProfilingAgent [candidate] (75.985 ms) : 0, 75985
Profiling [baseline] (75.186 ms) : 0, 75186
Profiling [candidate] (76.01 ms) : 0, 76010
LoadParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 24 cases. Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.20.0-SNAPSHOT~5599c5a44e, baseline=1.20.0-SNAPSHOT~4663dd598c
dateFormat X
axisFormat %s
section baseline
no_agent (1.33 ms) : 1311, 1348
. : milestone, 1330,
appsec (1.659 ms) : 1635, 1683
. : milestone, 1659,
iast (1.459 ms) : 1435, 1483
. : milestone, 1459,
profiling (1.465 ms) : 1439, 1491
. : milestone, 1465,
tracing (1.43 ms) : 1405, 1456
. : milestone, 1430,
section candidate
no_agent (1.322 ms) : 1303, 1341
. : milestone, 1322,
appsec (1.689 ms) : 1664, 1713
. : milestone, 1689,
iast (1.442 ms) : 1418, 1467
. : milestone, 1442,
profiling (1.474 ms) : 1448, 1500
. : milestone, 1474,
tracing (1.436 ms) : 1412, 1460
. : milestone, 1436,
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.20.0-SNAPSHOT~5599c5a44e, baseline=1.20.0-SNAPSHOT~4663dd598c
dateFormat X
axisFormat %s
section baseline
no_agent (351.533 µs) : 331, 372
. : milestone, 352,
appsec (656.46 µs) : 636, 677
. : milestone, 656,
iast (455.572 µs) : 435, 476
. : milestone, 456,
iast_FULL (516.515 µs) : 496, 537
. : milestone, 517,
iast_INACTIVE (428.113 µs) : 407, 449
. : milestone, 428,
profiling (444.149 µs) : 423, 465
. : milestone, 444,
tracing (430.72 µs) : 410, 452
. : milestone, 431,
section candidate
no_agent (355.464 µs) : 336, 375
. : milestone, 355,
appsec (654.682 µs) : 634, 675
. : milestone, 655,
iast (451.633 µs) : 431, 472
. : milestone, 452,
iast_FULL (514.295 µs) : 494, 535
. : milestone, 514,
iast_INACTIVE (432.313 µs) : 411, 454
. : milestone, 432,
profiling (436.768 µs) : 415, 458
. : milestone, 437,
tracing (427.212 µs) : 406, 448
. : milestone, 427,
|
mcculls
marked this pull request as ready for review
August 18, 2023 14:51
devinsba
approved these changes
Aug 18, 2023
bantonsson
approved these changes
Aug 18, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Does This Do
This PR avoids allocating a new
ContinuingScopewhen the top of the scope stack is already keeping the same span alive as the continuation. Instead we increment the existing scope's reference count and cancel the continuation.In other words instead of stacking another scope onto the stack for the same span, we collapse it into the existing scope.
The main difference is that we cancel the continuation immediately rather than when the scope finally closes, but I believe this is acceptable because the existing scope should already be keeping the trace alive - either by the span if it's on the original thread or by a different continuation (in the existing
ContinuingScope) if it's on a different thread.Motivation
Reduces the number of
ContinuingScopeallocations when using fork-join pools.