Skip to content
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

[ASM] Remove httpcontext from context store at the end of the request #6151

Merged
merged 2 commits into from
Oct 21, 2024

Conversation

anna-git
Copy link
Contributor

Summary of changes

Some logs show that we're accessing HttpContext properties when it has already been disposed. Stacktrace shows that it's at the beginning of running the waf, so this might be a simple fix for now

Reason for change

Implementation details

Test coverage

Other details

@datadog-ddstaging
Copy link

datadog-ddstaging bot commented Oct 14, 2024

Datadog Report

Branch report: anna/asm/remove-httpcontext-endrequest
Commit report: 4d5bb45
Test service: dd-trace-dotnet

✅ 0 Failed, 361413 Passed, 2090 Skipped, 17h 43m 7.85s Total Time

@andrewlock
Copy link
Member

andrewlock commented Oct 14, 2024

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:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

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 (6151) - mean (72ms)  : 69, 75
     .   : milestone, 72,
    master - mean (70ms)  : 68, 72
     .   : milestone, 70,

    section CallTarget+Inlining+NGEN
    This PR (6151) - mean (1,138ms)  : 1117, 1160
     .   : milestone, 1138,
    master - mean (1,111ms)  : 1087, 1135
     .   : milestone, 1111,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6151) - mean (112ms)  : 109, 116
     .   : milestone, 112,
    master - mean (109ms)  : 106, 111
     .   : milestone, 109,

    section CallTarget+Inlining+NGEN
    This PR (6151) - mean (791ms)  : 778, 805
     .   : milestone, 791,
    master - mean (772ms)  : 756, 789
     .   : milestone, 772,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6151) - mean (95ms)  : 92, 97
     .   : milestone, 95,
    master - mean (92ms)  : 89, 95
     .   : milestone, 92,

    section CallTarget+Inlining+NGEN
    This PR (6151) - mean (742ms)  : 727, 757
     .   : milestone, 742,
    master - mean (730ms)  : 714, 745
     .   : milestone, 730,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6151) - mean (191ms)  : 187, 195
     .   : milestone, 191,
    master - mean (189ms)  : 186, 192
     .   : milestone, 189,

    section CallTarget+Inlining+NGEN
    This PR (6151) - mean (1,198ms)  : 1180, 1215
     .   : milestone, 1198,
    master - mean (1,197ms)  : 1170, 1224
     .   : milestone, 1197,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6151) - mean (277ms)  : 274, 281
     .   : milestone, 277,
    master - mean (273ms)  : 269, 278
     .   : milestone, 273,

    section CallTarget+Inlining+NGEN
    This PR (6151) - mean (943ms)  : 926, 960
     .   : milestone, 943,
    master - mean (939ms)  : 919, 958
     .   : milestone, 939,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6151) - mean (265ms)  : 261, 270
     .   : milestone, 265,
    master - mean (263ms)  : 259, 266
     .   : milestone, 263,

    section CallTarget+Inlining+NGEN
    This PR (6151) - mean (923ms)  : 905, 941
     .   : milestone, 923,
    master - mean (926ms)  : 906, 947
     .   : milestone, 926,

Loading

@andrewlock
Copy link
Member

andrewlock commented Oct 14, 2024

Benchmarks Report for appsec 🐌

Benchmarks for #6151 compared to master:

  • 1 benchmarks are faster, with geometric mean 1.264
  • 1 benchmarks are slower, with geometric mean 1.129
  • 2 benchmarks have fewer allocations

The following thresholds were used for comparing the benchmark speeds:

  • Mann–Whitney U test with statistical test for significance of 5%
  • Only results indicating a difference greater than 10% and 0.3 ns are considered.

Allocation changes below 0.5% are ignored.

Benchmark details

Benchmarks.Trace.Asm.AppSecBodyBenchmark - Faster 🎉 Same allocations ✔️

Faster 🎉 in #6151

Benchmark base/diff Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody‑net6.0 1.264 192.95 152.66

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master AllCycleSimpleBody net6.0 72.8μs 107ns 414ns 0.0728 0 0 6 KB
master AllCycleSimpleBody netcoreapp3.1 63.4μs 127ns 493ns 0.094 0 0 6.95 KB
master AllCycleSimpleBody net472 49μs 27.8ns 100ns 1.32 0 0 8.34 KB
master AllCycleMoreComplexBody net6.0 80.1μs 175ns 676ns 0.121 0 0 9.51 KB
master AllCycleMoreComplexBody netcoreapp3.1 71μs 103ns 399ns 0.142 0 0 10.37 KB
master AllCycleMoreComplexBody net472 56.9μs 88.6ns 343ns 1.87 0.0284 0 11.85 KB
master ObjectExtractorSimpleBody net6.0 193ns 0.129ns 0.5ns 0.00395 0 0 280 B
master ObjectExtractorSimpleBody netcoreapp3.1 224ns 0.156ns 0.604ns 0.00371 0 0 272 B
master ObjectExtractorSimpleBody net472 165ns 0.217ns 0.839ns 0.0446 0 0 281 B
master ObjectExtractorMoreComplexBody net6.0 3.12μs 1.99ns 7.45ns 0.0532 0 0 3.78 KB
master ObjectExtractorMoreComplexBody netcoreapp3.1 3.92μs 2.63ns 9.83ns 0.0512 0 0 3.69 KB
master ObjectExtractorMoreComplexBody net472 4μs 5.72ns 22.2ns 0.603 0.00597 0 3.8 KB
#6151 AllCycleSimpleBody net6.0 76.7μs 105ns 406ns 0.0764 0 0 6 KB
#6151 AllCycleSimpleBody netcoreapp3.1 63.4μs 112ns 435ns 0.0953 0 0 6.95 KB
#6151 AllCycleSimpleBody net472 50μs 23.1ns 83.4ns 1.3 0 0 8.34 KB
#6151 AllCycleMoreComplexBody net6.0 81μs 82.7ns 320ns 0.122 0 0 9.51 KB
#6151 AllCycleMoreComplexBody netcoreapp3.1 72.5μs 112ns 435ns 0.108 0 0 10.36 KB
#6151 AllCycleMoreComplexBody net472 56.7μs 27.6ns 107ns 1.87 0.0284 0 11.85 KB
#6151 ObjectExtractorSimpleBody net6.0 153ns 0.133ns 0.515ns 0.00394 0 0 280 B
#6151 ObjectExtractorSimpleBody netcoreapp3.1 213ns 0.19ns 0.712ns 0.00378 0 0 272 B
#6151 ObjectExtractorSimpleBody net472 166ns 0.194ns 0.727ns 0.0446 0 0 281 B
#6151 ObjectExtractorMoreComplexBody net6.0 3.03μs 3.1ns 12ns 0.053 0 0 3.78 KB
#6151 ObjectExtractorMoreComplexBody netcoreapp3.1 4.07μs 2.14ns 8.31ns 0.051 0 0 3.69 KB
#6151 ObjectExtractorMoreComplexBody net472 3.88μs 3.43ns 12.8ns 0.603 0.00591 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.5μs 21.8ns 81.5ns 0.449 0 0 32.4 KB
master EncodeArgs netcoreapp3.1 54.4μs 23.4ns 90.5ns 0.432 0 0 32.4 KB
master EncodeArgs net472 67.2μs 45.6ns 176ns 5.16 0.0671 0 32.5 KB
master EncodeLegacyArgs net6.0 72.2μs 13ns 48.5ns 0 0 0 2.14 KB
master EncodeLegacyArgs netcoreapp3.1 103μs 61.4ns 230ns 0 0 0 2.14 KB
master EncodeLegacyArgs net472 151μs 49.9ns 187ns 0.306 0 0 2.15 KB
#6151 EncodeArgs net6.0 37.4μs 26ns 101ns 0.447 0 0 32.4 KB
#6151 EncodeArgs netcoreapp3.1 54.9μs 19.7ns 76.4ns 0.436 0 0 32.4 KB
#6151 EncodeArgs net472 66.8μs 36.2ns 140ns 5.14 0.0671 0 32.5 KB
#6151 EncodeLegacyArgs net6.0 71.2μs 36.6ns 127ns 0 0 0 2.14 KB
#6151 EncodeLegacyArgs netcoreapp3.1 105μs 144ns 558ns 0 0 0 2.14 KB
#6151 EncodeLegacyArgs net472 152μs 98.1ns 380ns 0.305 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 185μs 181ns 701ns 0 0 0 2.44 KB
master RunWafRealisticBenchmark netcoreapp3.1 195μs 110ns 411ns 0 0 0 2.39 KB
master RunWafRealisticBenchmark net472 209μs 150ns 580ns 0.314 0 0 2.46 KB
master RunWafRealisticBenchmarkWithAttack net6.0 123μs 52.9ns 205ns 0 0 0 1.47 KB
master RunWafRealisticBenchmarkWithAttack netcoreapp3.1 130μs 123ns 476ns 0 0 0 1.46 KB
master RunWafRealisticBenchmarkWithAttack net472 139μs 25.9ns 100ns 0.209 0 0 1.49 KB
#6151 RunWafRealisticBenchmark net6.0 187μs 150ns 560ns 0 0 0 2.44 KB
#6151 RunWafRealisticBenchmark netcoreapp3.1 198μs 237ns 919ns 0 0 0 2.39 KB
#6151 RunWafRealisticBenchmark net472 211μs 173ns 669ns 0.316 0 0 2.46 KB
#6151 RunWafRealisticBenchmarkWithAttack net6.0 125μs 68.9ns 267ns 0 0 0 1.47 KB
#6151 RunWafRealisticBenchmarkWithAttack netcoreapp3.1 132μs 104ns 373ns 0 0 0 1.46 KB
#6151 RunWafRealisticBenchmarkWithAttack net472 141μs 142ns 551ns 0.213 0 0 1.49 KB
Benchmarks.Trace.Iast.StringAspectsBenchmark - Slower ⚠️ Fewer allocations 🎉

Slower ⚠️ in #6151

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net6.0 1.129 62,100.00 70,100.00 bimodal

Fewer allocations 🎉 in #6151

Benchmark Base Allocated Diff Allocated Change Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 255.23 KB 253.85 KB -1.38 KB -0.54%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472 59.07 KB 57.3 KB -1.77 KB -2.99%

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StringConcatBenchmark net6.0 61.3μs 701ns 6.97μs 0 0 0 43.44 KB
master StringConcatBenchmark netcoreapp3.1 54.2μs 283ns 1.44μs 0 0 0 42.64 KB
master StringConcatBenchmark net472 37.5μs 65.2ns 235ns 0 0 0 59.07 KB
master StringConcatAspectBenchmark net6.0 314μs 1.77μs 12.6μs 0 0 0 255.23 KB
master StringConcatAspectBenchmark netcoreapp3.1 328μs 1.8μs 12.1μs 0 0 0 252.73 KB
master StringConcatAspectBenchmark net472 272μs 5.43μs 51.8μs 0 0 0 278.53 KB
#6151 StringConcatBenchmark net6.0 72.2μs 991ns 9.81μs 0 0 0 43.44 KB
#6151 StringConcatBenchmark netcoreapp3.1 59.5μs 789ns 7.57μs 0 0 0 42.64 KB
#6151 StringConcatBenchmark net472 38.8μs 219ns 1.46μs 0 0 0 57.3 KB
#6151 StringConcatAspectBenchmark net6.0 331μs 1.71μs 11.6μs 0 0 0 253.85 KB
#6151 StringConcatAspectBenchmark netcoreapp3.1 329μs 1.85μs 15.4μs 0 0 0 252.01 KB
#6151 StringConcatAspectBenchmark net472 301μs 6.03μs 58.1μs 0 0 0 278.53 KB

@andrewlock
Copy link
Member

andrewlock commented Oct 14, 2024

Benchmarks Report for tracer 🐌

Benchmarks for #6151 compared to master:

  • 1 benchmarks are slower, with geometric mean 1.135
  • All benchmarks have the same allocations

The following thresholds were used for comparing the benchmark speeds:

  • Mann–Whitney U test with statistical test for significance of 5%
  • Only results indicating a difference greater than 10% and 0.3 ns are considered.

Allocation changes below 0.5% are ignored.

Benchmark details

Benchmarks.Trace.ActivityBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 7.81μs 45.2ns 367ns 0.0114 0.0038 0 5.43 KB
master StartStopWithChild netcoreapp3.1 10μs 46.9ns 225ns 0.0195 0.00488 0 5.62 KB
master StartStopWithChild net472 17.1μs 93.8ns 601ns 1 0.278 0.0783 6.06 KB
#6151 StartStopWithChild net6.0 7.97μs 43.4ns 268ns 0.0149 0.00744 0 5.43 KB
#6151 StartStopWithChild netcoreapp3.1 9.95μs 52.8ns 264ns 0.0236 0.00942 0 5.62 KB
#6151 StartStopWithChild net472 16.9μs 76.2ns 295ns 1.03 0.322 0.0992 6.06 KB
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 482μs 190ns 711ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 636μs 453ns 1.76μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 837μs 587ns 2.27μs 0.44 0 0 3.3 KB
#6151 WriteAndFlushEnrichedTraces net6.0 472μs 218ns 787ns 0 0 0 2.7 KB
#6151 WriteAndFlushEnrichedTraces netcoreapp3.1 634μs 453ns 1.75μs 0 0 0 2.7 KB
#6151 WriteAndFlushEnrichedTraces net472 835μs 213ns 796ns 0.417 0 0 3.3 KB
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net6.0 196μs 1.17μs 11.5μs 0.199 0 0 18.45 KB
master SendRequest netcoreapp3.1 222μs 1.27μs 9.78μs 0.217 0 0 20.61 KB
master SendRequest net472 0.000796ns 0.000248ns 0.000959ns 0 0 0 0 b
#6151 SendRequest net6.0 202μs 1.17μs 10.2μs 0.19 0 0 18.45 KB
#6151 SendRequest netcoreapp3.1 231μs 1.42μs 14μs 0.231 0 0 20.61 KB
#6151 SendRequest net472 0.00114ns 0.000508ns 0.00197ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 579μs 1.58μs 6.1μs 0.576 0 0 41.77 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 675μs 2.6μs 9.71μs 0.34 0 0 41.74 KB
master WriteAndFlushEnrichedTraces net472 866μs 3.24μs 12.1μs 8.08 2.55 0.425 53.32 KB
#6151 WriteAndFlushEnrichedTraces net6.0 565μs 3μs 15.9μs 0.566 0 0 41.64 KB
#6151 WriteAndFlushEnrichedTraces netcoreapp3.1 676μs 3.35μs 14.2μs 0.34 0 0 41.73 KB
#6151 WriteAndFlushEnrichedTraces net472 886μs 3.59μs 13.9μs 8.3 2.62 0.437 53.32 KB
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteNonQuery net6.0 1.3μs 0.554ns 2.07ns 0.0143 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.82μs 0.576ns 2.16ns 0.0134 0 0 1.02 KB
master ExecuteNonQuery net472 2.03μs 2.81ns 10.9ns 0.156 0 0 987 B
#6151 ExecuteNonQuery net6.0 1.32μs 1.11ns 4.13ns 0.0141 0 0 1.02 KB
#6151 ExecuteNonQuery netcoreapp3.1 1.76μs 1.38ns 5.36ns 0.0141 0 0 1.02 KB
#6151 ExecuteNonQuery net472 2.1μs 1.61ns 6.23ns 0.156 0 0 987 B
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master CallElasticsearch net6.0 1.24μs 1.33ns 5.14ns 0.0137 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.6μs 2.07ns 8.01ns 0.0127 0 0 976 B
master CallElasticsearch net472 2.61μs 1.64ns 6.12ns 0.158 0 0 995 B
master CallElasticsearchAsync net6.0 1.3μs 1.12ns 4.33ns 0.0129 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.6μs 1.09ns 4.09ns 0.0136 0 0 1.02 KB
master CallElasticsearchAsync net472 2.7μs 1.99ns 7.18ns 0.167 0 0 1.05 KB
#6151 CallElasticsearch net6.0 1.27μs 1.63ns 6.31ns 0.0133 0 0 976 B
#6151 CallElasticsearch netcoreapp3.1 1.54μs 0.911ns 3.29ns 0.0131 0 0 976 B
#6151 CallElasticsearch net472 2.63μs 2.64ns 10.2ns 0.157 0 0 995 B
#6151 CallElasticsearchAsync net6.0 1.43μs 2.18ns 8.15ns 0.0137 0 0 952 B
#6151 CallElasticsearchAsync netcoreapp3.1 1.74μs 1.43ns 5.52ns 0.0139 0 0 1.02 KB
#6151 CallElasticsearchAsync net472 2.63μs 3.53ns 13.7ns 0.166 0 0 1.05 KB
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net6.0 1.34μs 0.711ns 2.75ns 0.0134 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.64μs 2.67ns 10.4ns 0.0124 0 0 952 B
master ExecuteAsync net472 1.8μs 1ns 3.89ns 0.145 0 0 915 B
#6151 ExecuteAsync net6.0 1.27μs 0.917ns 3.43ns 0.0133 0 0 952 B
#6151 ExecuteAsync netcoreapp3.1 1.64μs 0.844ns 3.16ns 0.0123 0 0 952 B
#6151 ExecuteAsync net472 1.83μs 0.872ns 3.26ns 0.145 0 0 915 B
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net6.0 4.17μs 1.47ns 5.68ns 0.0313 0 0 2.22 KB
master SendAsync netcoreapp3.1 5.09μs 7.48ns 29ns 0.0357 0 0 2.76 KB
master SendAsync net472 7.83μs 3.09ns 12ns 0.498 0 0 3.15 KB
#6151 SendAsync net6.0 4.24μs 1.45ns 5.42ns 0.0295 0 0 2.22 KB
#6151 SendAsync netcoreapp3.1 5.13μs 1.87ns 6.98ns 0.036 0 0 2.76 KB
#6151 SendAsync net472 7.82μs 2.34ns 8.74ns 0.497 0 0 3.15 KB
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 1.46μs 0.805ns 3.01ns 0.0235 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.16μs 1.26ns 4.55ns 0.0214 0 0 1.64 KB
master EnrichedLog net472 2.61μs 1.99ns 7.71ns 0.249 0 0 1.57 KB
#6151 EnrichedLog net6.0 1.49μs 0.729ns 2.82ns 0.023 0 0 1.64 KB
#6151 EnrichedLog netcoreapp3.1 2.23μs 1.15ns 4.29ns 0.022 0 0 1.64 KB
#6151 EnrichedLog net472 2.75μs 1.4ns 5.44ns 0.25 0 0 1.57 KB
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 119μs 197ns 762ns 0 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 123μs 99ns 384ns 0 0 0 4.28 KB
master EnrichedLog net472 154μs 131ns 509ns 0.684 0.228 0 4.46 KB
#6151 EnrichedLog net6.0 115μs 132ns 495ns 0 0 0 4.28 KB
#6151 EnrichedLog netcoreapp3.1 122μs 316ns 1.22μs 0 0 0 4.28 KB
#6151 EnrichedLog net472 153μs 91.8ns 356ns 0.689 0.23 0 4.46 KB
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 2.99μs 1.09ns 4.09ns 0.0299 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.17μs 2.43ns 9.09ns 0.0292 0 0 2.2 KB
master EnrichedLog net472 4.91μs 1.55ns 6.01ns 0.318 0 0 2.02 KB
#6151 EnrichedLog net6.0 3.03μs 1.2ns 4.48ns 0.0303 0 0 2.2 KB
#6151 EnrichedLog netcoreapp3.1 4.04μs 1.71ns 6.63ns 0.0305 0 0 2.2 KB
#6151 EnrichedLog net472 4.83μs 5.36ns 20.8ns 0.32 0 0 2.02 KB
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendReceive net6.0 1.38μs 1.25ns 4.83ns 0.0159 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.73μs 0.782ns 3.03ns 0.0157 0 0 1.14 KB
master SendReceive net472 2.1μs 1.12ns 4.35ns 0.183 0 0 1.16 KB
#6151 SendReceive net6.0 1.39μs 1.42ns 5.31ns 0.016 0 0 1.14 KB
#6151 SendReceive netcoreapp3.1 1.79μs 1.19ns 4.63ns 0.015 0 0 1.14 KB
#6151 SendReceive net472 2.11μs 0.872ns 3.26ns 0.183 0 0 1.16 KB
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 2.81μs 1.45ns 5.42ns 0.0225 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 4μs 4.22ns 16.4ns 0.022 0 0 1.65 KB
master EnrichedLog net472 4.34μs 3.77ns 14.6ns 0.322 0 0 2.04 KB
#6151 EnrichedLog net6.0 2.83μs 1.66ns 6.42ns 0.0227 0 0 1.6 KB
#6151 EnrichedLog netcoreapp3.1 4.03μs 5.71ns 20.6ns 0.0217 0 0 1.65 KB
#6151 EnrichedLog net472 4.55μs 2.14ns 7.72ns 0.322 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Slower ⚠️ Same allocations ✔️

Slower ⚠️ in #6151

Benchmark diff/base Base Median (ns) Diff Median (ns) Modality
Benchmarks.Trace.SpanBenchmark.StartFinishSpan‑netcoreapp3.1 1.135 559.89 635.49

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 401ns 0.386ns 1.49ns 0.00812 0 0 576 B
master StartFinishSpan netcoreapp3.1 560ns 0.997ns 3.73ns 0.00781 0 0 576 B
master StartFinishSpan net472 714ns 2.96ns 11.5ns 0.0915 0 0 578 B
master StartFinishScope net6.0 511ns 0.965ns 3.61ns 0.00996 0 0 696 B
master StartFinishScope netcoreapp3.1 808ns 0.753ns 2.82ns 0.00942 0 0 696 B
master StartFinishScope net472 921ns 1.45ns 5.63ns 0.105 0 0 658 B
#6151 StartFinishSpan net6.0 413ns 0.263ns 0.985ns 0.00803 0 0 576 B
#6151 StartFinishSpan netcoreapp3.1 636ns 0.437ns 1.69ns 0.00789 0 0 576 B
#6151 StartFinishSpan net472 707ns 1.37ns 5.31ns 0.0916 0 0 578 B
#6151 StartFinishScope net6.0 541ns 0.162ns 0.607ns 0.00982 0 0 696 B
#6151 StartFinishScope netcoreapp3.1 750ns 0.645ns 2.5ns 0.00924 0 0 696 B
#6151 StartFinishScope net472 895ns 0.394ns 1.42ns 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 600ns 0.862ns 3.34ns 0.00962 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 973ns 1.12ns 4.32ns 0.00959 0 0 696 B
master RunOnMethodBegin net472 1.2μs 1.53ns 5.93ns 0.104 0 0 658 B
#6151 RunOnMethodBegin net6.0 654ns 0.326ns 1.26ns 0.00987 0 0 696 B
#6151 RunOnMethodBegin netcoreapp3.1 1.05μs 0.401ns 1.5ns 0.00944 0 0 696 B
#6151 RunOnMethodBegin net472 1.15μs 0.793ns 3.07ns 0.104 0 0 658 B

@andrewlock
Copy link
Member

andrewlock commented Oct 14, 2024

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 (6151) (11.141M)   : 0, 11140714
    master (11.075M)   : 0, 11075136
    benchmarks/2.9.0 (11.081M)   : 0, 11080577

    section Automatic
    This PR (6151) (7.441M)   : 0, 7441141
    master (7.367M)   : 0, 7366951
    benchmarks/2.9.0 (7.732M)   : 0, 7732233

    section Trace stats
    master (7.787M)   : 0, 7786534

    section Manual
    master (11.035M)   : 0, 11035295

    section Manual + Automatic
    This PR (6151) (6.820M)   : 0, 6819581
    master (6.868M)   : 0, 6867674

    section DD_TRACE_ENABLED=0
    master (10.287M)   : 0, 10286929

Loading
gantt
    title Throughput Linux arm64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (6151) (9.639M)   : 0, 9639221
    master (9.623M)   : 0, 9623464
    benchmarks/2.9.0 (9.798M)   : 0, 9798067

    section Automatic
    This PR (6151) (6.573M)   : 0, 6573007
    master (6.552M)   : 0, 6552321

    section Trace stats
    master (6.804M)   : 0, 6804137

    section Manual
    master (9.681M)   : 0, 9680841

    section Manual + Automatic
    This PR (6151) (5.905M)   : 0, 5905340
    master (6.129M)   : 0, 6129325

    section DD_TRACE_ENABLED=0
    master (8.872M)   : 0, 8871923

Loading
gantt
    title Throughput Windows x64 (Total requests) 
    dateFormat  X
    axisFormat %s
    section Baseline
    This PR (6151) (9.807M)   : 0, 9807281
    master (9.890M)   : 0, 9889878
    benchmarks/2.9.0 (10.067M)   : 0, 10067315

    section Automatic
    This PR (6151) (6.722M)   : 0, 6722136
    master (6.497M)   : 0, 6496699
    benchmarks/2.9.0 (7.552M)   : 0, 7552193

    section Trace stats
    master (7.060M)   : 0, 7060412

    section Manual
    master (9.783M)   : 0, 9783254

    section Manual + Automatic
    This PR (6151) (6.216M)   : 0, 6215931
    master (6.100M)   : 0, 6099575

    section DD_TRACE_ENABLED=0
    master (9.233M)   : 0, 9233471

Loading

Copy link
Contributor

@NachoEchevarria NachoEchevarria left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@anna-git anna-git marked this pull request as ready for review October 14, 2024 14:00
@anna-git anna-git requested review from a team as code owners October 14, 2024 14:00
@@ -689,6 +691,8 @@ private void OnHostingUnhandledException(object arg)
AspNetCoreRequestHandler.HandleAspNetCoreException(tracer, CurrentSecurity, rootSpan, httpContext, unhandledStruct.Exception);
}

CoreHttpContextStore.Instance.Remove();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if you want this here? 🤔 I believe OnHostingHttpRequestInStop is still called after OnHostingUnhandledException, so you'll end up not having a context earlier than you expect if you remove it here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point I removed it! 4d5bb45

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double checked, and it's indeed called after OnHostingUnhandledException

@@ -670,6 +670,8 @@ private void OnHostingHttpRequestInStop(object arg)
AspNetCoreRequestHandler.StopAspNetCorePipelineScope(tracer, CurrentSecurity, rootScope, httpContext);
}

CoreHttpContextStore.Instance.Remove();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if you should call this in AspNetCoreRequestHandler.StopAspNetCorePipelineScope() as well 🤔 StopAspNetCorePipelineScope is called outside of this pipeline too, in Azure Functions for example, so may be safest to add a call there (calling it twice should be safe I think?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point!! thanks
4d5bb45
yes it should be safe as its just setting a value to null..

Copy link
Member

@andrewlock andrewlock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice :shipit:

@anna-git anna-git merged commit f4a80d3 into master Oct 21, 2024
75 checks passed
@anna-git anna-git deleted the anna/asm/remove-httpcontext-endrequest branch October 21, 2024 12:22
@github-actions github-actions bot added this to the vNext-v3 milestone Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants