-
Notifications
You must be signed in to change notification settings - Fork 312
Improve thread-safety of ScopeContext.restore
when swapping Kotlin coroutine contexts
#9491
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
Conversation
🎯 Code Coverage 🔗 Commit SHA: 526162b | Docs | Was this helpful? Give us feedback! |
BenchmarksStartupParameters
See matching parameters
SummaryFound 1 performance improvements and 0 performance regressions! Performance is the same for 50 metrics, 8 unstable metrics.
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.54.0-SNAPSHOT~526162b544, baseline=1.54.0-SNAPSHOT~f02c1d14c0
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.066 s) : 0, 1065983
Total [baseline] (10.692 s) : 0, 10692230
Agent [candidate] (1.058 s) : 0, 1058365
Total [candidate] (10.716 s) : 0, 10715997
section appsec
Agent [baseline] (1.245 s) : 0, 1245275
Total [baseline] (10.963 s) : 0, 10962619
Agent [candidate] (1.233 s) : 0, 1233347
Total [candidate] (10.96 s) : 0, 10959846
section iast
Agent [baseline] (1.193 s) : 0, 1193313
Total [baseline] (10.991 s) : 0, 10991326
Agent [candidate] (1.196 s) : 0, 1196047
Total [candidate] (10.977 s) : 0, 10977173
section profiling
Agent [baseline] (1.208 s) : 0, 1208092
Total [baseline] (10.957 s) : 0, 10956709
Agent [candidate] (1.207 s) : 0, 1207441
Total [candidate] (10.93 s) : 0, 10929811
gantt
title petclinic - break down per module: candidate=1.54.0-SNAPSHOT~526162b544, baseline=1.54.0-SNAPSHOT~f02c1d14c0
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.46 ms) : 0, 1460
crashtracking [candidate] (1.453 ms) : 0, 1453
BytebuddyAgent [baseline] (735.919 ms) : 0, 735919
BytebuddyAgent [candidate] (730.703 ms) : 0, 730703
GlobalTracer [baseline] (253.336 ms) : 0, 253336
GlobalTracer [candidate] (251.757 ms) : 0, 251757
AppSec [baseline] (30.728 ms) : 0, 30728
AppSec [candidate] (30.65 ms) : 0, 30650
Debugger [baseline] (6.447 ms) : 0, 6447
Debugger [candidate] (6.356 ms) : 0, 6356
Remote Config [baseline] (720.282 µs) : 0, 720
Remote Config [candidate] (688.503 µs) : 0, 689
Telemetry [baseline] (16.23 ms) : 0, 16230
Telemetry [candidate] (15.64 ms) : 0, 15640
section appsec
crashtracking [baseline] (1.473 ms) : 0, 1473
crashtracking [candidate] (1.456 ms) : 0, 1456
BytebuddyAgent [baseline] (762.643 ms) : 0, 762643
BytebuddyAgent [candidate] (755.207 ms) : 0, 755207
GlobalTracer [baseline] (248.075 ms) : 0, 248075
GlobalTracer [candidate] (245.11 ms) : 0, 245110
IAST [baseline] (24.0 ms) : 0, 24000
IAST [candidate] (23.799 ms) : 0, 23799
AppSec [baseline] (172.347 ms) : 0, 172347
AppSec [candidate] (171.473 ms) : 0, 171473
Debugger [baseline] (6.149 ms) : 0, 6149
Debugger [candidate] (6.001 ms) : 0, 6001
Remote Config [baseline] (663.048 µs) : 0, 663
Remote Config [candidate] (621.019 µs) : 0, 621
Telemetry [baseline] (8.556 ms) : 0, 8556
Telemetry [candidate] (8.371 ms) : 0, 8371
section iast
crashtracking [baseline] (1.481 ms) : 0, 1481
crashtracking [candidate] (1.469 ms) : 0, 1469
BytebuddyAgent [baseline] (853.873 ms) : 0, 853873
BytebuddyAgent [candidate] (857.516 ms) : 0, 857516
GlobalTracer [baseline] (247.135 ms) : 0, 247135
GlobalTracer [candidate] (247.122 ms) : 0, 247122
IAST [baseline] (27.464 ms) : 0, 27464
IAST [candidate] (29.528 ms) : 0, 29528
AppSec [baseline] (27.453 ms) : 0, 27453
AppSec [candidate] (24.593 ms) : 0, 24593
Debugger [baseline] (6.024 ms) : 0, 6024
Debugger [candidate] (6.066 ms) : 0, 6066
Remote Config [baseline] (593.947 µs) : 0, 594
Remote Config [candidate] (595.361 µs) : 0, 595
Telemetry [baseline] (8.095 ms) : 0, 8095
Telemetry [candidate] (8.031 ms) : 0, 8031
section profiling
crashtracking [baseline] (1.422 ms) : 0, 1422
crashtracking [candidate] (1.443 ms) : 0, 1443
BytebuddyAgent [baseline] (760.91 ms) : 0, 760910
BytebuddyAgent [candidate] (760.344 ms) : 0, 760344
GlobalTracer [baseline] (232.686 ms) : 0, 232686
GlobalTracer [candidate] (232.852 ms) : 0, 232852
AppSec [baseline] (30.264 ms) : 0, 30264
AppSec [candidate] (31.029 ms) : 0, 31029
Debugger [baseline] (10.493 ms) : 0, 10493
Debugger [candidate] (7.395 ms) : 0, 7395
Remote Config [baseline] (729.788 µs) : 0, 730
Remote Config [candidate] (704.577 µs) : 0, 705
Telemetry [baseline] (12.517 ms) : 0, 12517
Telemetry [candidate] (14.938 ms) : 0, 14938
ProfilingAgent [baseline] (108.007 ms) : 0, 108007
ProfilingAgent [candidate] (107.856 ms) : 0, 107856
Profiling [baseline] (108.66 ms) : 0, 108660
Profiling [candidate] (108.507 ms) : 0, 108507
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.54.0-SNAPSHOT~526162b544, baseline=1.54.0-SNAPSHOT~f02c1d14c0
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.066 s) : 0, 1065921
Total [baseline] (8.635 s) : 0, 8634549
Agent [candidate] (1.062 s) : 0, 1061958
Total [candidate] (8.643 s) : 0, 8642658
section iast
Agent [baseline] (1.189 s) : 0, 1188955
Total [baseline] (9.322 s) : 0, 9321763
Agent [candidate] (1.19 s) : 0, 1190299
Total [candidate] (9.315 s) : 0, 9314935
gantt
title insecure-bank - break down per module: candidate=1.54.0-SNAPSHOT~526162b544, baseline=1.54.0-SNAPSHOT~f02c1d14c0
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.476 ms) : 0, 1476
crashtracking [candidate] (1.445 ms) : 0, 1445
BytebuddyAgent [baseline] (736.097 ms) : 0, 736097
BytebuddyAgent [candidate] (732.688 ms) : 0, 732688
GlobalTracer [baseline] (252.902 ms) : 0, 252902
GlobalTracer [candidate] (252.511 ms) : 0, 252511
AppSec [baseline] (30.738 ms) : 0, 30738
AppSec [candidate] (30.642 ms) : 0, 30642
Debugger [baseline] (6.416 ms) : 0, 6416
Debugger [candidate] (6.385 ms) : 0, 6385
Remote Config [baseline] (701.353 µs) : 0, 701
Remote Config [candidate] (686.788 µs) : 0, 687
Telemetry [baseline] (16.558 ms) : 0, 16558
Telemetry [candidate] (16.573 ms) : 0, 16573
section iast
crashtracking [baseline] (1.459 ms) : 0, 1459
crashtracking [candidate] (1.447 ms) : 0, 1447
BytebuddyAgent [baseline] (852.147 ms) : 0, 852147
BytebuddyAgent [candidate] (852.807 ms) : 0, 852807
GlobalTracer [baseline] (246.533 ms) : 0, 246533
GlobalTracer [candidate] (244.131 ms) : 0, 244131
AppSec [baseline] (24.463 ms) : 0, 24463
AppSec [candidate] (25.624 ms) : 0, 25624
Debugger [baseline] (6.016 ms) : 0, 6016
Debugger [candidate] (6.075 ms) : 0, 6075
Remote Config [baseline] (591.405 µs) : 0, 591
Remote Config [candidate] (591.657 µs) : 0, 592
Telemetry [baseline] (8.153 ms) : 0, 8153
Telemetry [candidate] (8.207 ms) : 0, 8207
IAST [baseline] (28.68 ms) : 0, 28680
IAST [candidate] (30.496 ms) : 0, 30496
LoadParameters
See matching parameters
SummaryFound 0 performance improvements and 1 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.54.0-SNAPSHOT~526162b544, baseline=1.54.0-SNAPSHOT~f02c1d14c0
dateFormat X
axisFormat %s
section baseline
no_agent (4.344 ms) : 4295, 4393
. : milestone, 4344,
iast (9.568 ms) : 9409, 9728
. : milestone, 9568,
iast_FULL (14.472 ms) : 14181, 14764
. : milestone, 14472,
iast_GLOBAL (10.337 ms) : 10156, 10518
. : milestone, 10337,
profiling (9.04 ms) : 8898, 9181
. : milestone, 9040,
tracing (7.612 ms) : 7506, 7718
. : milestone, 7612,
section candidate
no_agent (4.315 ms) : 4266, 4364
. : milestone, 4315,
iast (9.878 ms) : 9705, 10050
. : milestone, 9878,
iast_FULL (14.085 ms) : 13804, 14366
. : milestone, 14085,
iast_GLOBAL (10.432 ms) : 10235, 10629
. : milestone, 10432,
profiling (8.889 ms) : 8753, 9026
. : milestone, 8889,
tracing (7.394 ms) : 7282, 7506
. : milestone, 7394,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.54.0-SNAPSHOT~526162b544, baseline=1.54.0-SNAPSHOT~f02c1d14c0
dateFormat X
axisFormat %s
section baseline
no_agent (37.737 ms) : 37442, 38032
. : milestone, 37737,
appsec (46.411 ms) : 46006, 46816
. : milestone, 46411,
code_origins (45.907 ms) : 45514, 46300
. : milestone, 45907,
iast (44.638 ms) : 44250, 45026
. : milestone, 44638,
profiling (48.385 ms) : 47935, 48835
. : milestone, 48385,
tracing (44.307 ms) : 43934, 44680
. : milestone, 44307,
section candidate
no_agent (37.001 ms) : 36705, 37298
. : milestone, 37001,
appsec (46.858 ms) : 46456, 47259
. : milestone, 46858,
code_origins (46.861 ms) : 46453, 47268
. : milestone, 46861,
iast (45.312 ms) : 44907, 45716
. : milestone, 45312,
profiling (50.901 ms) : 50426, 51376
. : milestone, 50901,
tracing (43.596 ms) : 43212, 43980
. : milestone, 43596,
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 biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.54.0-SNAPSHOT~526162b544, baseline=1.54.0-SNAPSHOT~f02c1d14c0
dateFormat X
axisFormat %s
section baseline
no_agent (14.945 s) : 14945000, 14945000
. : milestone, 14945000,
appsec (14.881 s) : 14881000, 14881000
. : milestone, 14881000,
iast (18.522 s) : 18522000, 18522000
. : milestone, 18522000,
iast_GLOBAL (17.765 s) : 17765000, 17765000
. : milestone, 17765000,
profiling (15.492 s) : 15492000, 15492000
. : milestone, 15492000,
tracing (14.804 s) : 14804000, 14804000
. : milestone, 14804000,
section candidate
no_agent (15.466 s) : 15466000, 15466000
. : milestone, 15466000,
appsec (14.814 s) : 14814000, 14814000
. : milestone, 14814000,
iast (18.529 s) : 18529000, 18529000
. : milestone, 18529000,
iast_GLOBAL (18.188 s) : 18188000, 18188000
. : milestone, 18188000,
profiling (15.97 s) : 15970000, 15970000
. : milestone, 15970000,
tracing (14.875 s) : 14875000, 14875000
. : milestone, 14875000,
Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.54.0-SNAPSHOT~526162b544, baseline=1.54.0-SNAPSHOT~f02c1d14c0
dateFormat X
axisFormat %s
section baseline
no_agent (1.485 ms) : 1473, 1497
. : milestone, 1485,
appsec (2.466 ms) : 2415, 2516
. : milestone, 2466,
iast (2.21 ms) : 2148, 2273
. : milestone, 2210,
iast_GLOBAL (2.256 ms) : 2193, 2319
. : milestone, 2256,
profiling (2.077 ms) : 2025, 2130
. : milestone, 2077,
tracing (2.031 ms) : 1982, 2080
. : milestone, 2031,
section candidate
no_agent (1.487 ms) : 1475, 1498
. : milestone, 1487,
appsec (2.507 ms) : 2454, 2559
. : milestone, 2507,
iast (2.212 ms) : 2150, 2275
. : milestone, 2212,
iast_GLOBAL (2.26 ms) : 2197, 2323
. : milestone, 2260,
profiling (2.049 ms) : 1998, 2099
. : milestone, 2049,
tracing (2.025 ms) : 1976, 2073
. : milestone, 2025,
|
For other threads restore shallow copy, using parent and active scopes captured when the original context stack was swapped out.
4bc2b1e
to
526162b
Compare
ScopeContext.restore
when swapping Kotlin coroutine contexts
What Does This Do
When swapping context stacks, restore full stack on original thread. For other threads restore a temporary shallow copy of the stack, using parent and active scopes captured when the original context stack was swapped out.
Motivation
Avoids potential issue if the same
ScopeContext
ends up being restored on different threads. We only need to restore the parent and active scopes when the context is temporarily swapped onto another thread. The full stack can continue to be restored onto the original thread. By capturing minimal information at the time the stack gets swapped out we avoid any potential thread-safety issues without incurring a performance penalty.Contributor Checklist
type:
and (comp:
orinst:
) labels in addition to any usefull labelsclose
,fix
or any linking keywords when referencing an issue.Use
solves
instead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]