[ASM] Segregate asm and iast contexts functionality#6118
Conversation
Datadog ReportBranch report: ✅ 0 Failed, 364300 Passed, 2082 Skipped, 16h 36m 26.95s Total Time New Flaky Tests (1)
|
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing the following branches/commits: Execution-time benchmarks measure the whole time it takes to execute a program. And are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are shown in red. The following thresholds were used for comparing the execution times:
Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard. Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph). gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6118) - mean (71ms) : 68, 73
. : milestone, 71,
master - mean (70ms) : 68, 73
. : milestone, 70,
section CallTarget+Inlining+NGEN
This PR (6118) - mean (1,107ms) : 1076, 1138
. : milestone, 1107,
master - mean (1,109ms) : 1085, 1132
. : milestone, 1109,
gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6118) - mean (109ms) : 106, 113
. : milestone, 109,
master - mean (110ms) : 107, 114
. : milestone, 110,
section CallTarget+Inlining+NGEN
This PR (6118) - mean (776ms) : 762, 789
. : milestone, 776,
master - mean (773ms) : 756, 790
. : milestone, 773,
gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6118) - mean (93ms) : 90, 96
. : milestone, 93,
master - mean (93ms) : 89, 97
. : milestone, 93,
section CallTarget+Inlining+NGEN
This PR (6118) - mean (730ms) : 710, 750
. : milestone, 730,
master - mean (731ms) : 710, 753
. : milestone, 731,
gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6118) - mean (191ms) : 188, 194
. : milestone, 191,
master - mean (190ms) : 187, 194
. : milestone, 190,
section CallTarget+Inlining+NGEN
This PR (6118) - mean (1,201ms) : 1172, 1230
. : milestone, 1201,
master - mean (1,200ms) : 1173, 1227
. : milestone, 1200,
gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6118) - mean (276ms) : 273, 279
. : milestone, 276,
master - mean (276ms) : 272, 281
. : milestone, 276,
section CallTarget+Inlining+NGEN
This PR (6118) - mean (940ms) : 925, 955
. : milestone, 940,
master - mean (940ms) : 923, 957
. : milestone, 940,
gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (6118) - mean (266ms) : 262, 270
. : milestone, 266,
master - mean (265ms) : 262, 269
. : milestone, 265,
section CallTarget+Inlining+NGEN
This PR (6118) - mean (929ms) : 908, 951
. : milestone, 929,
master - mean (924ms) : 904, 944
. : milestone, 924,
|
Benchmarks Report for appsec 🐌Benchmarks for #6118 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.Asm.AppSecBodyBenchmark - Slower
|
| Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody‑net472 | 1.307 | 169.32 | 221.31 |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | AllCycleSimpleBody |
net6.0 | 72.5μs | 71.4ns | 267ns | 0.0723 | 0 | 0 | 6.01 KB |
| master | AllCycleSimpleBody |
netcoreapp3.1 | 62.2μs | 93.4ns | 362ns | 0.0938 | 0 | 0 | 6.95 KB |
| master | AllCycleSimpleBody |
net472 | 49.1μs | 76ns | 284ns | 1.31 | 0 | 0 | 8.34 KB |
| master | AllCycleMoreComplexBody |
net6.0 | 79.3μs | 80.1ns | 310ns | 0.117 | 0 | 0 | 9.51 KB |
| master | AllCycleMoreComplexBody |
netcoreapp3.1 | 71.1μs | 63.2ns | 236ns | 0.142 | 0 | 0 | 10.37 KB |
| master | AllCycleMoreComplexBody |
net472 | 55.8μs | 93.7ns | 363ns | 1.86 | 0.0278 | 0 | 11.85 KB |
| master | ObjectExtractorSimpleBody |
net6.0 | 147ns | 0.146ns | 0.548ns | 0.00394 | 0 | 0 | 280 B |
| master | ObjectExtractorSimpleBody |
netcoreapp3.1 | 199ns | 0.704ns | 2.73ns | 0.00363 | 0 | 0 | 272 B |
| master | ObjectExtractorSimpleBody |
net472 | 169ns | 0.0834ns | 0.323ns | 0.0446 | 0 | 0 | 281 B |
| master | ObjectExtractorMoreComplexBody |
net6.0 | 3.15μs | 2.42ns | 8.4ns | 0.0537 | 0 | 0 | 3.78 KB |
| master | ObjectExtractorMoreComplexBody |
netcoreapp3.1 | 3.93μs | 2.36ns | 8.84ns | 0.0509 | 0 | 0 | 3.69 KB |
| master | ObjectExtractorMoreComplexBody |
net472 | 3.85μs | 7.78ns | 30.1ns | 0.602 | 0.00774 | 0 | 3.8 KB |
| #6118 | AllCycleSimpleBody |
net6.0 | 72.9μs | 83.1ns | 311ns | 0.0733 | 0 | 0 | 6 KB |
| #6118 | AllCycleSimpleBody |
netcoreapp3.1 | 62.5μs | 90.4ns | 350ns | 0.093 | 0 | 0 | 6.95 KB |
| #6118 | AllCycleSimpleBody |
net472 | 49μs | 65.4ns | 253ns | 1.32 | 0 | 0 | 8.34 KB |
| #6118 | AllCycleMoreComplexBody |
net6.0 | 78.7μs | 60.8ns | 227ns | 0.118 | 0 | 0 | 9.51 KB |
| #6118 | AllCycleMoreComplexBody |
netcoreapp3.1 | 69.9μs | 99.2ns | 384ns | 0.139 | 0 | 0 | 10.37 KB |
| #6118 | AllCycleMoreComplexBody |
net472 | 56.1μs | 49.8ns | 186ns | 1.88 | 0.0281 | 0 | 11.85 KB |
| #6118 | ObjectExtractorSimpleBody |
net6.0 | 145ns | 0.111ns | 0.415ns | 0.00393 | 0 | 0 | 280 B |
| #6118 | ObjectExtractorSimpleBody |
netcoreapp3.1 | 196ns | 0.151ns | 0.585ns | 0.00373 | 0 | 0 | 272 B |
| #6118 | ObjectExtractorSimpleBody |
net472 | 221ns | 0.137ns | 0.531ns | 0.0445 | 0 | 0 | 281 B |
| #6118 | ObjectExtractorMoreComplexBody |
net6.0 | 3.04μs | 1.82ns | 7.05ns | 0.0535 | 0 | 0 | 3.78 KB |
| #6118 | ObjectExtractorMoreComplexBody |
netcoreapp3.1 | 3.89μs | 2.97ns | 11.5ns | 0.0503 | 0 | 0 | 3.69 KB |
| #6118 | ObjectExtractorMoreComplexBody |
net472 | 4.24μs | 5.18ns | 19.4ns | 0.602 | 0.00638 | 0 | 3.8 KB |
Benchmarks.Trace.Asm.AppSecEncoderBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | EncodeArgs |
net6.0 | 37.2μs | 18.1ns | 70.3ns | 0.447 | 0 | 0 | 32.4 KB |
| master | EncodeArgs |
netcoreapp3.1 | 54.3μs | 32.6ns | 122ns | 0.434 | 0 | 0 | 32.4 KB |
| master | EncodeArgs |
net472 | 66.7μs | 43.8ns | 170ns | 5.16 | 0.0666 | 0 | 32.5 KB |
| master | EncodeLegacyArgs |
net6.0 | 71.9μs | 62.1ns | 241ns | 0 | 0 | 0 | 2.14 KB |
| master | EncodeLegacyArgs |
netcoreapp3.1 | 104μs | 117ns | 454ns | 0 | 0 | 0 | 2.14 KB |
| master | EncodeLegacyArgs |
net472 | 150μs | 96.1ns | 372ns | 0.3 | 0 | 0 | 2.15 KB |
| #6118 | EncodeArgs |
net6.0 | 37.9μs | 26.6ns | 103ns | 0.451 | 0 | 0 | 32.4 KB |
| #6118 | EncodeArgs |
netcoreapp3.1 | 55.2μs | 26.2ns | 101ns | 0.438 | 0 | 0 | 32.4 KB |
| #6118 | EncodeArgs |
net472 | 66.9μs | 62.1ns | 240ns | 5.16 | 0.067 | 0 | 32.5 KB |
| #6118 | EncodeLegacyArgs |
net6.0 | 70.6μs | 128ns | 497ns | 0 | 0 | 0 | 2.14 KB |
| #6118 | EncodeLegacyArgs |
netcoreapp3.1 | 108μs | 57.6ns | 216ns | 0 | 0 | 0 | 2.14 KB |
| #6118 | EncodeLegacyArgs |
net472 | 150μs | 188ns | 727ns | 0.299 | 0 | 0 | 2.15 KB |
Benchmarks.Trace.Asm.AppSecWafBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | RunWafRealisticBenchmark |
net6.0 | 186μs | 213ns | 825ns | 0 | 0 | 0 | 2.44 KB |
| master | RunWafRealisticBenchmark |
netcoreapp3.1 | 199μs | 178ns | 640ns | 0 | 0 | 0 | 2.39 KB |
| master | RunWafRealisticBenchmark |
net472 | 209μs | 42.8ns | 166ns | 0.314 | 0 | 0 | 2.46 KB |
| master | RunWafRealisticBenchmarkWithAttack |
net6.0 | 123μs | 41.5ns | 144ns | 0 | 0 | 0 | 1.47 KB |
| master | RunWafRealisticBenchmarkWithAttack |
netcoreapp3.1 | 131μs | 117ns | 452ns | 0 | 0 | 0 | 1.46 KB |
| master | RunWafRealisticBenchmarkWithAttack |
net472 | 141μs | 84.8ns | 328ns | 0.209 | 0 | 0 | 1.49 KB |
| #6118 | RunWafRealisticBenchmark |
net6.0 | 183μs | 110ns | 426ns | 0 | 0 | 0 | 2.44 KB |
| #6118 | RunWafRealisticBenchmark |
netcoreapp3.1 | 197μs | 215ns | 832ns | 0 | 0 | 0 | 2.39 KB |
| #6118 | RunWafRealisticBenchmark |
net472 | 210μs | 57.9ns | 224ns | 0.314 | 0 | 0 | 2.46 KB |
| #6118 | RunWafRealisticBenchmarkWithAttack |
net6.0 | 122μs | 80.1ns | 310ns | 0 | 0 | 0 | 1.47 KB |
| #6118 | RunWafRealisticBenchmarkWithAttack |
netcoreapp3.1 | 130μs | 86.3ns | 323ns | 0 | 0 | 0 | 1.46 KB |
| #6118 | RunWafRealisticBenchmarkWithAttack |
net472 | 138μs | 41.5ns | 155ns | 0.207 | 0 | 0 | 1.49 KB |
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ More allocations ⚠️
More allocations ⚠️ in #6118
Benchmark
Base Allocated
Diff Allocated
Change
Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0
254.47 KB
265.52 KB
11.05 KB
4.34%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472
57.9 KB
59.74 KB
1.85 KB
3.19%
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 | 254.47 KB | 265.52 KB | 11.05 KB | 4.34% |
| Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472 | 57.9 KB | 59.74 KB | 1.85 KB | 3.19% |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | StringConcatBenchmark |
net6.0 | 57.7μs | 780ns | 7.65μs | 0 | 0 | 0 | 43.44 KB |
| master | StringConcatBenchmark |
netcoreapp3.1 | 52.3μs | 246ns | 953ns | 0 | 0 | 0 | 42.64 KB |
| master | StringConcatBenchmark |
net472 | 37.3μs | 81.5ns | 282ns | 0 | 0 | 0 | 57.9 KB |
| master | StringConcatAspectBenchmark |
net6.0 | 309μs | 1.7μs | 10.5μs | 0 | 0 | 0 | 254.47 KB |
| master | StringConcatAspectBenchmark |
netcoreapp3.1 | 302μs | 5.32μs | 52.2μs | 0 | 0 | 0 | 253.93 KB |
| master | StringConcatAspectBenchmark |
net472 | 278μs | 6.02μs | 59.6μs | 0 | 0 | 0 | 278.53 KB |
| #6118 | StringConcatBenchmark |
net6.0 | 59.8μs | 683ns | 6.77μs | 0 | 0 | 0 | 43.44 KB |
| #6118 | StringConcatBenchmark |
netcoreapp3.1 | 56.7μs | 577ns | 5.56μs | 0 | 0 | 0 | 42.64 KB |
| #6118 | StringConcatBenchmark |
net472 | 37.9μs | 190ns | 806ns | 0 | 0 | 0 | 59.74 KB |
| #6118 | StringConcatAspectBenchmark |
net6.0 | 326μs | 1.69μs | 7.93μs | 0 | 0 | 0 | 265.52 KB |
| #6118 | StringConcatAspectBenchmark |
netcoreapp3.1 | 329μs | 1.81μs | 12.7μs | 0 | 0 | 0 | 252.85 KB |
| #6118 | StringConcatAspectBenchmark |
net472 | 291μs | 6.92μs | 67.8μs | 0 | 0 | 0 | 278.53 KB |
Benchmarks Report for tracer 🐌Benchmarks for #6118 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.ActivityBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SpanBenchmark - Faster 🎉 Same allocations ✔️
|
| Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑net6.0 | 1.142 | 462.55 | 404.92 |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | StartFinishSpan |
net6.0 | 463ns | 0.188ns | 0.727ns | 0.00812 | 0 | 0 | 576 B |
| master | StartFinishSpan |
netcoreapp3.1 | 565ns | 0.448ns | 1.74ns | 0.00788 | 0 | 0 | 576 B |
| master | StartFinishSpan |
net472 | 608ns | 0.301ns | 1.17ns | 0.0917 | 0 | 0 | 578 B |
| master | StartFinishScope |
net6.0 | 473ns | 0.271ns | 1.05ns | 0.00973 | 0 | 0 | 696 B |
| master | StartFinishScope |
netcoreapp3.1 | 729ns | 0.47ns | 1.82ns | 0.00931 | 0 | 0 | 696 B |
| master | StartFinishScope |
net472 | 809ns | 0.491ns | 1.9ns | 0.104 | 0 | 0 | 658 B |
| #6118 | StartFinishSpan |
net6.0 | 406ns | 0.664ns | 2.57ns | 0.00805 | 0 | 0 | 576 B |
| #6118 | StartFinishSpan |
netcoreapp3.1 | 617ns | 3.1ns | 13.1ns | 0.00762 | 0 | 0 | 576 B |
| #6118 | StartFinishSpan |
net472 | 646ns | 0.232ns | 0.898ns | 0.0916 | 0 | 0 | 578 B |
| #6118 | StartFinishScope |
net6.0 | 492ns | 0.194ns | 0.75ns | 0.00985 | 0 | 0 | 696 B |
| #6118 | StartFinishScope |
netcoreapp3.1 | 721ns | 0.283ns | 1.06ns | 0.00948 | 0 | 0 | 696 B |
| #6118 | StartFinishScope |
net472 | 896ns | 3.6ns | 14ns | 0.104 | 0 | 0 | 658 B |
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | RunOnMethodBegin |
net6.0 | 656ns | 0.36ns | 1.39ns | 0.00977 | 0 | 0 | 696 B |
| master | RunOnMethodBegin |
netcoreapp3.1 | 936ns | 0.689ns | 2.48ns | 0.00951 | 0 | 0 | 696 B |
| master | RunOnMethodBegin |
net472 | 1.15μs | 0.35ns | 1.35ns | 0.105 | 0 | 0 | 658 B |
| #6118 | RunOnMethodBegin |
net6.0 | 594ns | 0.304ns | 1.18ns | 0.00956 | 0 | 0 | 696 B |
| #6118 | RunOnMethodBegin |
netcoreapp3.1 | 919ns | 0.598ns | 2.32ns | 0.00961 | 0 | 0 | 696 B |
| #6118 | RunOnMethodBegin |
net472 | 1.15μs | 0.618ns | 2.39ns | 0.104 | 0 | 0 | 658 B |
Throughput/Crank Report ⚡Throughput results for AspNetCoreSimpleController comparing the following branches/commits: Cases where throughput results for the PR are worse than latest master (5% drop or greater), results are shown in red. Note that these results are based on a single point-in-time result for each branch. For full results, see one of the many, many dashboards! gantt
title Throughput Linux x64 (Total requests)
dateFormat X
axisFormat %s
section Baseline
This PR (6118) (10.976M) : 0, 10976479
master (11.067M) : 0, 11067199
benchmarks/2.9.0 (11.081M) : 0, 11080577
section Automatic
This PR (6118) (7.304M) : 0, 7304430
master (7.314M) : 0, 7314309
benchmarks/2.9.0 (7.732M) : 0, 7732233
section Trace stats
master (7.522M) : 0, 7522105
section Manual
master (11.089M) : 0, 11089039
section Manual + Automatic
This PR (6118) (6.754M) : 0, 6754234
master (6.818M) : 0, 6818236
section DD_TRACE_ENABLED=0
master (10.233M) : 0, 10233045
gantt
title Throughput Linux arm64 (Total requests)
dateFormat X
axisFormat %s
section Baseline
This PR (6118) (9.542M) : 0, 9542014
master (9.628M) : 0, 9628028
benchmarks/2.9.0 (9.798M) : 0, 9798067
section Automatic
This PR (6118) (6.543M) : 0, 6542855
master (6.472M) : 0, 6472350
section Trace stats
master (6.828M) : 0, 6827760
section Manual
master (9.756M) : 0, 9756410
section Manual + Automatic
This PR (6118) (6.246M) : 0, 6245809
master (6.092M) : 0, 6091664
section DD_TRACE_ENABLED=0
master (9.056M) : 0, 9056055
gantt
title Throughput Windows x64 (Total requests)
dateFormat X
axisFormat %s
section Baseline
This PR (6118) (10.012M) : 0, 10012328
master (10.362M) : 0, 10362363
benchmarks/2.9.0 (10.067M) : 0, 10067315
section Automatic
This PR (6118) (6.672M) : 0, 6671505
master (6.848M) : 0, 6848211
benchmarks/2.9.0 (7.552M) : 0, 7552193
section Trace stats
master (7.513M) : 0, 7513310
section Manual
master (10.234M) : 0, 10233822
section Manual + Automatic
This PR (6118) (6.348M) : 0, 6348464
master (6.352M) : 0, 6351972
section DD_TRACE_ENABLED=0
master (9.543M) : 0, 9543014
|
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| private AppSecRequestContext GetRequestContext() | ||
| /// <summary> Gets the AppSec context </summary> | ||
| internal AppSecRequestContext AppSecRequestContext |
There was a problem hiding this comment.
nit: I wonder if it's worth making this a method called GetOrCreateAppSecRequestContext()? I'm undecided if there's any value in that tbh, just a thought 🤷
Mostly because the subtle difference with IastRequestContext being potentially null, while AppSecRequestContext is never null slightly concerns me 🤔
There was a problem hiding this comment.
I thought the same, but I preferred the symmetry, and the nullable return does the job also, IMO
Summary of changes
As suggested in this PR comment by @andrewlock , it is better to remove ASM and IAST specific functionality from the
TraceContextto theis respective contexts.Reason for change
Code cleanup
Implementation details
Test coverage
Other details