Don't use System.Runtime.CompilerServices.Unsafe in .NET Core 2.1#7955
Don't use System.Runtime.CompilerServices.Unsafe in .NET Core 2.1#7955andrewlock merged 3 commits intomasterfrom
System.Runtime.CompilerServices.Unsafe in .NET Core 2.1#7955Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (7955) and master. ✅ No regressions detected - check the details below Full Metrics ComparisonFakeDbCommand
HttpMessageHandler
Comparison explanationExecution-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 highlighted 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). Duration chartsFakeDbCommand (.NET Framework 4.8)gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7955) - mean (76ms) : 71, 81
master - mean (75ms) : 70, 81
section Bailout
This PR (7955) - mean (81ms) : 75, 88
master - mean (84ms) : 75, 92
section CallTarget+Inlining+NGEN
This PR (7955) - mean (1,074ms) : 1002, 1146
master - mean (1,074ms) : 1022, 1126
FakeDbCommand (.NET Core 3.1)gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7955) - mean (117ms) : 110, 125
master - mean (118ms) : 112, 125
section Bailout
This PR (7955) - mean (118ms) : 112, 124
master - mean (120ms) : 113, 127
section CallTarget+Inlining+NGEN
This PR (7955) - mean (766ms) : 720, 811
master - mean (771ms) : 729, 812
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7955) - mean (105ms) : 100, 109
master - mean (104ms) : 96, 111
section Bailout
This PR (7955) - mean (106ms) : 100, 111
master - mean (106ms) : 99, 112
section CallTarget+Inlining+NGEN
This PR (7955) - mean (704ms) : 677, 730
master - mean (717ms) : 664, 769
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7955) - mean (103ms) : 96, 110
master - mean (104ms) : 96, 112
section Bailout
This PR (7955) - mean (105ms) : 97, 113
master - mean (104ms) : 97, 110
section CallTarget+Inlining+NGEN
This PR (7955) - mean (674ms) : 637, 712
master - mean (686ms) : 658, 714
HttpMessageHandler (.NET Framework 4.8)gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7955) - mean (193ms) : 189, 197
master - mean (193ms) : 189, 197
section Bailout
This PR (7955) - mean (196ms) : 194, 199
master - mean (197ms) : 194, 199
section CallTarget+Inlining+NGEN
This PR (7955) - mean (1,120ms) : 1057, 1184
master - mean (1,132ms) : 1050, 1214
HttpMessageHandler (.NET Core 3.1)gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7955) - mean (276ms) : 272, 280
master - mean (277ms) : 271, 282
section Bailout
This PR (7955) - mean (277ms) : 272, 282
master - mean (278ms) : 274, 282
section CallTarget+Inlining+NGEN
This PR (7955) - mean (909ms) : 854, 964
master - mean (910ms) : 866, 954
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7955) - mean (269ms) : 264, 274
master - mean (270ms) : 263, 277
section Bailout
This PR (7955) - mean (269ms) : 266, 272
master - mean (269ms) : 266, 273
section CallTarget+Inlining+NGEN
This PR (7955) - mean (888ms) : 838, 939
master - mean (888ms) : 842, 933
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7955) - mean (268ms) : 263, 273
master - mean (269ms) : 263, 275
section Bailout
This PR (7955) - mean (268ms) : 265, 272
master - mean (268ms) : 264, 272
section CallTarget+Inlining+NGEN
This PR (7955) - mean (824ms) : 806, 842
master - mean (824ms) : 805, 844
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
BenchmarksBenchmarks Report for benchmark platform 🐌Benchmarks for #7955 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 ✔️ More allocations
|
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces‑net472 | 3.26 KB | 3.33 KB | 64 B | 1.96% |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | WriteAndFlushEnrichedTraces |
net6.0 | 1.27ms | 481ns | 1.86μs | 0 | 0 | 0 | 2.7 KB |
| master | WriteAndFlushEnrichedTraces |
netcoreapp3.1 | 1.37ms | 250ns | 902ns | 0 | 0 | 0 | 2.7 KB |
| master | WriteAndFlushEnrichedTraces |
net472 | 1.7ms | 3.13μs | 12.1μs | 0 | 0 | 0 | 3.26 KB |
| #7955 | WriteAndFlushEnrichedTraces |
net6.0 | 1.27ms | 801ns | 3.1μs | 0 | 0 | 0 | 2.7 KB |
| #7955 | WriteAndFlushEnrichedTraces |
netcoreapp3.1 | 1.39ms | 211ns | 791ns | 0 | 0 | 0 | 2.7 KB |
| #7955 | WriteAndFlushEnrichedTraces |
net472 | 1.72ms | 1.1μs | 4.25μs | 0 | 0 | 0 | 3.33 KB |
Benchmarks.Trace.Asm.AppSecBodyBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | AllCycleSimpleBody |
net6.0 | 1.11μs | 0.365ns | 1.41ns | 0 | 0 | 0 | 1.22 KB |
| master | AllCycleSimpleBody |
netcoreapp3.1 | 1.37μs | 7.82ns | 58ns | 0 | 0 | 0 | 1.2 KB |
| master | AllCycleSimpleBody |
net472 | 1.01μs | 0.974ns | 3.77ns | 0.192 | 0 | 0 | 1.23 KB |
| master | AllCycleMoreComplexBody |
net6.0 | 7.51μs | 39.2ns | 204ns | 0 | 0 | 0 | 4.72 KB |
| master | AllCycleMoreComplexBody |
netcoreapp3.1 | 9μs | 43.8ns | 191ns | 0 | 0 | 0 | 4.62 KB |
| master | AllCycleMoreComplexBody |
net472 | 7.62μs | 2.48ns | 8.95ns | 0.724 | 0 | 0 | 4.74 KB |
| master | ObjectExtractorSimpleBody |
net6.0 | 353ns | 1.98ns | 12.5ns | 0 | 0 | 0 | 280 B |
| master | ObjectExtractorSimpleBody |
netcoreapp3.1 | 392ns | 2.13ns | 12.2ns | 0 | 0 | 0 | 272 B |
| master | ObjectExtractorSimpleBody |
net472 | 308ns | 0.00934ns | 0.0324ns | 0.0434 | 0 | 0 | 281 B |
| master | ObjectExtractorMoreComplexBody |
net6.0 | 6.41μs | 34.4ns | 188ns | 0 | 0 | 0 | 3.78 KB |
| master | ObjectExtractorMoreComplexBody |
netcoreapp3.1 | 7.85μs | 37.9ns | 161ns | 0 | 0 | 0 | 3.69 KB |
| master | ObjectExtractorMoreComplexBody |
net472 | 6.7μs | 6.73ns | 26.1ns | 0.573 | 0 | 0 | 3.8 KB |
| #7955 | AllCycleSimpleBody |
net6.0 | 1.09μs | 6.23ns | 44ns | 0 | 0 | 0 | 1.22 KB |
| #7955 | AllCycleSimpleBody |
netcoreapp3.1 | 1.38μs | 7.87ns | 57.9ns | 0 | 0 | 0 | 1.2 KB |
| #7955 | AllCycleSimpleBody |
net472 | 1.01μs | 0.708ns | 2.55ns | 0.192 | 0 | 0 | 1.23 KB |
| #7955 | AllCycleMoreComplexBody |
net6.0 | 7.49μs | 34.3ns | 133ns | 0 | 0 | 0 | 4.72 KB |
| #7955 | AllCycleMoreComplexBody |
netcoreapp3.1 | 8.98μs | 47.2ns | 231ns | 0 | 0 | 0 | 4.62 KB |
| #7955 | AllCycleMoreComplexBody |
net472 | 7.63μs | 3.35ns | 13ns | 0.723 | 0 | 0 | 4.74 KB |
| #7955 | ObjectExtractorSimpleBody |
net6.0 | 323ns | 1.88ns | 15.1ns | 0 | 0 | 0 | 280 B |
| #7955 | ObjectExtractorSimpleBody |
netcoreapp3.1 | 394ns | 2.18ns | 12.5ns | 0 | 0 | 0 | 272 B |
| #7955 | ObjectExtractorSimpleBody |
net472 | 300ns | 0.0186ns | 0.0671ns | 0.0438 | 0 | 0 | 281 B |
| #7955 | ObjectExtractorMoreComplexBody |
net6.0 | 6.5μs | 26.7ns | 103ns | 0 | 0 | 0 | 3.78 KB |
| #7955 | ObjectExtractorMoreComplexBody |
netcoreapp3.1 | 7.82μs | 37.6ns | 155ns | 0 | 0 | 0 | 3.69 KB |
| #7955 | ObjectExtractorMoreComplexBody |
net472 | 6.81μs | 3.37ns | 13.1ns | 0.58 | 0 | 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 | 75.6μs | 20.9ns | 81.1ns | 0 | 0 | 0 | 32.4 KB |
| master | EncodeArgs |
netcoreapp3.1 | 97.6μs | 275ns | 1.03μs | 0 | 0 | 0 | 32.4 KB |
| master | EncodeArgs |
net472 | 108μs | 12.3ns | 47.5ns | 4.88 | 0 | 0 | 32.5 KB |
| master | EncodeLegacyArgs |
net6.0 | 144μs | 326ns | 1.26μs | 0 | 0 | 0 | 2.14 KB |
| master | EncodeLegacyArgs |
netcoreapp3.1 | 199μs | 137ns | 529ns | 0 | 0 | 0 | 2.14 KB |
| master | EncodeLegacyArgs |
net472 | 264μs | 37.1ns | 144ns | 0 | 0 | 0 | 2.14 KB |
| #7955 | EncodeArgs |
net6.0 | 77.4μs | 242ns | 905ns | 0 | 0 | 0 | 32.4 KB |
| #7955 | EncodeArgs |
netcoreapp3.1 | 97.8μs | 329ns | 1.27μs | 0 | 0 | 0 | 32.4 KB |
| #7955 | EncodeArgs |
net472 | 108μs | 16.1ns | 58ns | 4.87 | 0 | 0 | 32.5 KB |
| #7955 | EncodeLegacyArgs |
net6.0 | 145μs | 25.8ns | 96.7ns | 0 | 0 | 0 | 2.14 KB |
| #7955 | EncodeLegacyArgs |
netcoreapp3.1 | 200μs | 203ns | 787ns | 0 | 0 | 0 | 2.14 KB |
| #7955 | EncodeLegacyArgs |
net472 | 263μs | 37.1ns | 139ns | 0 | 0 | 0 | 2.14 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 | 421μs | 1.21μs | 4.2μs | 0 | 0 | 0 | 4.55 KB |
| master | RunWafRealisticBenchmark |
netcoreapp3.1 | 438μs | 1.31μs | 4.54μs | 0 | 0 | 0 | 4.48 KB |
| master | RunWafRealisticBenchmark |
net472 | 486μs | 378ns | 1.36μs | 0 | 0 | 0 | 0 b |
| master | RunWafRealisticBenchmarkWithAttack |
net6.0 | 302μs | 871ns | 3.14μs | 0 | 0 | 0 | 2.24 KB |
| master | RunWafRealisticBenchmarkWithAttack |
netcoreapp3.1 | 340μs | 3.31μs | 31.4μs | 0 | 0 | 0 | 2.22 KB |
| master | RunWafRealisticBenchmarkWithAttack |
net472 | 363μs | 195ns | 704ns | 0 | 0 | 0 | 0 b |
| #7955 | RunWafRealisticBenchmark |
net6.0 | 430μs | 1.97μs | 7.37μs | 0 | 0 | 0 | 4.55 KB |
| #7955 | RunWafRealisticBenchmark |
netcoreapp3.1 | 454μs | 2.65μs | 24μs | 0 | 0 | 0 | 4.48 KB |
| #7955 | RunWafRealisticBenchmark |
net472 | 489μs | 534ns | 2μs | 0 | 0 | 0 | 0 b |
| #7955 | RunWafRealisticBenchmarkWithAttack |
net6.0 | 305μs | 1.19μs | 5.7μs | 0 | 0 | 0 | 2.24 KB |
| #7955 | RunWafRealisticBenchmarkWithAttack |
netcoreapp3.1 | 369μs | 3.57μs | 34.6μs | 0 | 0 | 0 | 2.22 KB |
| #7955 | RunWafRealisticBenchmarkWithAttack |
net472 | 360μs | 273ns | 947ns | 0 | 0 | 0 | 0 b |
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 | 85μs | 263ns | 1.02μs | 0 | 0 | 0 | 18.97 KB |
| master | SendRequest |
netcoreapp3.1 | 96.8μs | 502ns | 2.97μs | 0 | 0 | 0 | 21.18 KB |
| master | SendRequest |
net472 | 0ns | 0ns | 0ns | 0 | 0 | 0 | 0 b |
| #7955 | SendRequest |
net6.0 | 83.2μs | 113ns | 422ns | 0 | 0 | 0 | 18.97 KB |
| #7955 | SendRequest |
netcoreapp3.1 | 98.3μs | 473ns | 2.01μs | 0 | 0 | 0 | 21.18 KB |
| #7955 | SendRequest |
net472 | 0ns | 0ns | 0ns | 0 | 0 | 0 | 0 b |
Benchmarks.Trace.CharSliceBenchmark - Slower ⚠️ Same allocations ✔️
Slower ⚠️ in #7955
Benchmark
diff/base
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice‑netcoreapp3.1
1.806
2,163,000.00
3,907,150.00
| Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice‑netcoreapp3.1 | 1.806 | 2,163,000.00 | 3,907,150.00 |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | OriginalCharSlice |
net6.0 | 1.9ms | 767ns | 2.87μs | 0 | 0 | 0 | 640 KB |
| master | OriginalCharSlice |
netcoreapp3.1 | 2.18ms | 6.86μs | 43.4μs | 0 | 0 | 0 | 640 KB |
| master | OriginalCharSlice |
net472 | 2.61ms | 503ns | 1.88μs | 0 | 0 | 0 | 638.98 KB |
| master | OptimizedCharSlice |
net6.0 | 1.41ms | 514ns | 1.92μs | 0 | 0 | 0 | 0 b |
| master | OptimizedCharSlice |
netcoreapp3.1 | 2.73ms | 1.09μs | 4.06μs | 0 | 0 | 0 | 0 b |
| master | OptimizedCharSlice |
net472 | 1.92ms | 873ns | 3.38μs | 0 | 0 | 0 | 0 b |
| master | OptimizedCharSliceWithPool |
net6.0 | 1.06ms | 481ns | 1.73μs | 0 | 0 | 0 | 0 b |
| master | OptimizedCharSliceWithPool |
netcoreapp3.1 | 1.96ms | 1.82μs | 6.83μs | 0 | 0 | 0 | 0 b |
| master | OptimizedCharSliceWithPool |
net472 | 1.14ms | 823ns | 3.19μs | 0 | 0 | 0 | 0 b |
| #7955 | OriginalCharSlice |
net6.0 | 2.06ms | 1.59μs | 5.94μs | 0 | 0 | 0 | 640 KB |
| #7955 | OriginalCharSlice |
netcoreapp3.1 | 3.91ms | 573ns | 2.14μs | 0 | 0 | 0 | 640.05 KB |
| #7955 | OriginalCharSlice |
net472 | 2.65ms | 777ns | 2.91μs | 0 | 0 | 0 | 638.98 KB |
| #7955 | OptimizedCharSlice |
net6.0 | 1.54ms | 272ns | 1.02μs | 0 | 0 | 0 | 0 b |
| #7955 | OptimizedCharSlice |
netcoreapp3.1 | 2.8ms | 512ns | 1.91μs | 0 | 0 | 0 | 0 b |
| #7955 | OptimizedCharSlice |
net472 | 1.96ms | 1.5μs | 5.8μs | 0 | 0 | 0 | 0 b |
| #7955 | OptimizedCharSliceWithPool |
net6.0 | 1.07ms | 1.65μs | 6.39μs | 0 | 0 | 0 | 0 b |
| #7955 | OptimizedCharSliceWithPool |
netcoreapp3.1 | 1.87ms | 2.66μs | 10.3μs | 0 | 0 | 0 | 0 b |
| #7955 | OptimizedCharSliceWithPool |
net472 | 1.13ms | 659ns | 2.55μs | 0 | 0 | 0 | 0 b |
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ More allocations ⚠️
More allocations ⚠️ in #7955
Benchmark
Base Allocated
Diff Allocated
Change
Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑netcoreapp3.1
41.92 KB
42.14 KB
218 B
0.52%
Fewer allocations 🎉 in #7955
Benchmark
Base Allocated
Diff Allocated
Change
Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net472
56.05 KB
55.37 KB
-673 B
-1.20%
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑netcoreapp3.1 | 41.92 KB | 42.14 KB | 218 B | 0.52% |
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net472 | 56.05 KB | 55.37 KB | -673 B | -1.20% |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | WriteAndFlushEnrichedTraces |
net6.0 | 630μs | 1.19μs | 4.63μs | 0 | 0 | 0 | 41.67 KB |
| master | WriteAndFlushEnrichedTraces |
netcoreapp3.1 | 685μs | 3.98μs | 33.5μs | 0 | 0 | 0 | 41.92 KB |
| master | WriteAndFlushEnrichedTraces |
net472 | 919μs | 3.53μs | 13.2μs | 8.33 | 4.17 | 0 | 56.05 KB |
| #7955 | WriteAndFlushEnrichedTraces |
net6.0 | 682μs | 3.94μs | 34.6μs | 0 | 0 | 0 | 41.71 KB |
| #7955 | WriteAndFlushEnrichedTraces |
netcoreapp3.1 | 686μs | 916ns | 3.55μs | 0 | 0 | 0 | 42.14 KB |
| #7955 | WriteAndFlushEnrichedTraces |
net472 | 971μs | 4.94μs | 22.7μs | 4.46 | 0 | 0 | 55.37 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.9μs | 0.352ns | 1.32ns | 0 | 0 | 0 | 968 B |
| master | ExecuteNonQuery |
netcoreapp3.1 | 2.59μs | 8.08ns | 31.3ns | 0 | 0 | 0 | 960 B |
| master | ExecuteNonQuery |
net472 | 2.75μs | 4.48ns | 16.8ns | 0.137 | 0 | 0 | 931 B |
| #7955 | ExecuteNonQuery |
net6.0 | 2μs | 4.44ns | 17.2ns | 0 | 0 | 0 | 968 B |
| #7955 | ExecuteNonQuery |
netcoreapp3.1 | 2.44μs | 11.4ns | 44ns | 0 | 0 | 0 | 960 B |
| #7955 | ExecuteNonQuery |
net472 | 2.74μs | 4.12ns | 15.9ns | 0.137 | 0 | 0 | 931 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.68μs | 6.24ns | 24.2ns | 0 | 0 | 0 | 952 B |
| master | CallElasticsearch |
netcoreapp3.1 | 2.21μs | 10.9ns | 44.8ns | 0 | 0 | 0 | 968 B |
| master | CallElasticsearch |
net472 | 3.58μs | 4.73ns | 18.3ns | 0.139 | 0 | 0 | 955 B |
| master | CallElasticsearchAsync |
net6.0 | 1.72μs | 8.32ns | 35.3ns | 0 | 0 | 0 | 928 B |
| master | CallElasticsearchAsync |
netcoreapp3.1 | 2.32μs | 8.82ns | 34.2ns | 0 | 0 | 0 | 1.02 KB |
| master | CallElasticsearchAsync |
net472 | 3.42μs | 2.28ns | 8.23ns | 0.154 | 0 | 0 | 1.01 KB |
| #7955 | CallElasticsearch |
net6.0 | 1.67μs | 1.89ns | 6.8ns | 0 | 0 | 0 | 952 B |
| #7955 | CallElasticsearch |
netcoreapp3.1 | 2.15μs | 10.8ns | 49.6ns | 0 | 0 | 0 | 968 B |
| #7955 | CallElasticsearch |
net472 | 3.45μs | 3.06ns | 11.9ns | 0.137 | 0 | 0 | 955 B |
| #7955 | CallElasticsearchAsync |
net6.0 | 1.77μs | 2.92ns | 10.9ns | 0 | 0 | 0 | 928 B |
| #7955 | CallElasticsearchAsync |
netcoreapp3.1 | 2.27μs | 9.61ns | 37.2ns | 0 | 0 | 0 | 1.02 KB |
| #7955 | CallElasticsearchAsync |
net472 | 3.44μs | 4.14ns | 16ns | 0.155 | 0 | 0 | 1.01 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.8μs | 7.17ns | 26.8ns | 0 | 0 | 0 | 896 B |
| master | ExecuteAsync |
netcoreapp3.1 | 2.34μs | 11ns | 41.3ns | 0 | 0 | 0 | 896 B |
| master | ExecuteAsync |
net472 | 2.52μs | 1.31ns | 5.08ns | 0.126 | 0 | 0 | 858 B |
| #7955 | ExecuteAsync |
net6.0 | 1.8μs | 4.99ns | 18.7ns | 0 | 0 | 0 | 896 B |
| #7955 | ExecuteAsync |
netcoreapp3.1 | 2.41μs | 6.76ns | 26.2ns | 0 | 0 | 0 | 896 B |
| #7955 | ExecuteAsync |
net472 | 2.59μs | 1.69ns | 6.53ns | 0.13 | 0 | 0 | 858 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 | 6.54μs | 18.5ns | 69.3ns | 0 | 0 | 0 | 2.29 KB |
| master | SendAsync |
netcoreapp3.1 | 8.49μs | 26.8ns | 104ns | 0 | 0 | 0 | 2.83 KB |
| master | SendAsync |
net472 | 12μs | 9.41ns | 36.4ns | 0.484 | 0 | 0 | 3.08 KB |
| #7955 | SendAsync |
net6.0 | 6.96μs | 8.81ns | 34.1ns | 0 | 0 | 0 | 2.29 KB |
| #7955 | SendAsync |
netcoreapp3.1 | 8.47μs | 18.7ns | 69.8ns | 0 | 0 | 0 | 2.83 KB |
| #7955 | SendAsync |
net472 | 11.9μs | 7.99ns | 30.9ns | 0.475 | 0 | 0 | 3.08 KB |
Benchmarks.Trace.Iast.StringAspectsBenchmark - Slower ⚠️ More allocations ⚠️
Slower ⚠️ in #7955
Benchmark
diff/base
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0
1.136
437,150.00
496,650.00
More allocations ⚠️ in #7955
Benchmark
Base Allocated
Diff Allocated
Change
Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0
246.35 KB
274.11 KB
27.76 KB
11.27%
| Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 | 1.136 | 437,150.00 | 496,650.00 |
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net6.0 | 246.35 KB | 274.11 KB | 27.76 KB | 11.27% |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | StringConcatBenchmark |
net6.0 | 44.6μs | 239ns | 1.72μs | 0 | 0 | 0 | 42.51 KB |
| master | StringConcatBenchmark |
netcoreapp3.1 | 48.2μs | 259ns | 1.32μs | 0 | 0 | 0 | 42.54 KB |
| master | StringConcatBenchmark |
net472 | 56.7μs | 282ns | 1.29μs | 0 | 0 | 0 | 49.15 KB |
| master | StringConcatAspectBenchmark |
net6.0 | 439μs | 1.91μs | 6.88μs | 0 | 0 | 0 | 246.35 KB |
| master | StringConcatAspectBenchmark |
netcoreapp3.1 | 518μs | 1.88μs | 7.51μs | 0 | 0 | 0 | 272.16 KB |
| master | StringConcatAspectBenchmark |
net472 | 395μs | 2.03μs | 9.74μs | 0 | 0 | 0 | 270.34 KB |
| #7955 | StringConcatBenchmark |
net6.0 | 41.8μs | 220ns | 1.03μs | 0 | 0 | 0 | 42.51 KB |
| #7955 | StringConcatBenchmark |
netcoreapp3.1 | 52.2μs | 687ns | 6.76μs | 0 | 0 | 0 | 42.54 KB |
| #7955 | StringConcatBenchmark |
net472 | 57.1μs | 115ns | 416ns | 0 | 0 | 0 | 49.15 KB |
| #7955 | StringConcatAspectBenchmark |
net6.0 | 498μs | 1.93μs | 13.1μs | 0 | 0 | 0 | 274.11 KB |
| #7955 | StringConcatAspectBenchmark |
netcoreapp3.1 | 451μs | 5.27μs | 51.6μs | 0 | 0 | 0 | 271.82 KB |
| #7955 | StringConcatAspectBenchmark |
net472 | 398μs | 2.12μs | 11.2μs | 0 | 0 | 0 | 270.34 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 | 2.68μs | 14ns | 72.8ns | 0 | 0 | 0 | 1.69 KB |
| master | EnrichedLog |
netcoreapp3.1 | 3.51μs | 17.3ns | 71.5ns | 0 | 0 | 0 | 1.7 KB |
| master | EnrichedLog |
net472 | 3.93μs | 3.67ns | 14.2ns | 0.237 | 0 | 0 | 1.6 KB |
| #7955 | EnrichedLog |
net6.0 | 2.68μs | 12.9ns | 53.1ns | 0 | 0 | 0 | 1.69 KB |
| #7955 | EnrichedLog |
netcoreapp3.1 | 3.51μs | 17.9ns | 80.2ns | 0 | 0 | 0 | 1.7 KB |
| #7955 | EnrichedLog |
net472 | 3.9μs | 3.92ns | 15.2ns | 0.253 | 0 | 0 | 1.6 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 | 123μs | 47.8ns | 172ns | 0 | 0 | 0 | 4.31 KB |
| master | EnrichedLog |
netcoreapp3.1 | 128μs | 25.6ns | 99.1ns | 0 | 0 | 0 | 4.31 KB |
| master | EnrichedLog |
net472 | 168μs | 29.6ns | 111ns | 0 | 0 | 0 | 4.51 KB |
| #7955 | EnrichedLog |
net6.0 | 123μs | 28.4ns | 110ns | 0 | 0 | 0 | 4.31 KB |
| #7955 | EnrichedLog |
netcoreapp3.1 | 127μs | 85.3ns | 308ns | 0 | 0 | 0 | 4.31 KB |
| #7955 | EnrichedLog |
net472 | 167μs | 71.1ns | 256ns | 0 | 0 | 0 | 4.51 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 | 4.95μs | 18ns | 67.2ns | 0 | 0 | 0 | 2.24 KB |
| master | EnrichedLog |
netcoreapp3.1 | 6.79μs | 20.8ns | 80.4ns | 0 | 0 | 0 | 2.26 KB |
| master | EnrichedLog |
net472 | 7.61μs | 6.45ns | 25ns | 0.304 | 0 | 0 | 2.05 KB |
| #7955 | EnrichedLog |
net6.0 | 5.03μs | 13.6ns | 52.6ns | 0 | 0 | 0 | 2.24 KB |
| #7955 | EnrichedLog |
netcoreapp3.1 | 6.67μs | 20.4ns | 73.5ns | 0 | 0 | 0 | 2.26 KB |
| #7955 | EnrichedLog |
net472 | 7.84μs | 6.39ns | 24.7ns | 0.312 | 0 | 0 | 2.05 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.95μs | 9.74ns | 43.6ns | 0 | 0 | 0 | 1.12 KB |
| master | SendReceive |
netcoreapp3.1 | 2.45μs | 11.2ns | 43.4ns | 0 | 0 | 0 | 1.14 KB |
| master | SendReceive |
net472 | 3.04μs | 5.5ns | 21.3ns | 0.165 | 0 | 0 | 1.12 KB |
| #7955 | SendReceive |
net6.0 | 1.95μs | 9.41ns | 39.9ns | 0 | 0 | 0 | 1.12 KB |
| #7955 | SendReceive |
netcoreapp3.1 | 2.52μs | 12.5ns | 52.8ns | 0 | 0 | 0 | 1.14 KB |
| #7955 | SendReceive |
net472 | 2.9μs | 3.45ns | 13.3ns | 0.174 | 0 | 0 | 1.12 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 | 4.41μs | 1.11ns | 4.29ns | 0 | 0 | 0 | 1.58 KB |
| master | EnrichedLog |
netcoreapp3.1 | 5.59μs | 16.4ns | 61.4ns | 0 | 0 | 0 | 1.63 KB |
| master | EnrichedLog |
net472 | 6.72μs | 6.45ns | 25ns | 0.302 | 0 | 0 | 2.03 KB |
| #7955 | EnrichedLog |
net6.0 | 4.44μs | 6.68ns | 25ns | 0 | 0 | 0 | 1.58 KB |
| #7955 | EnrichedLog |
netcoreapp3.1 | 5.93μs | 4.96ns | 18.6ns | 0 | 0 | 0 | 1.63 KB |
| #7955 | EnrichedLog |
net472 | 6.86μs | 7.42ns | 28.7ns | 0.307 | 0 | 0 | 2.03 KB |
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | StartFinishSpan |
net6.0 | 778ns | 4.23ns | 22.4ns | 0 | 0 | 0 | 520 B |
| master | StartFinishSpan |
netcoreapp3.1 | 936ns | 4.32ns | 16.1ns | 0 | 0 | 0 | 520 B |
| master | StartFinishSpan |
net472 | 883ns | 0.151ns | 0.584ns | 0.0797 | 0 | 0 | 522 B |
| master | StartFinishScope |
net6.0 | 906ns | 0.526ns | 1.97ns | 0 | 0 | 0 | 640 B |
| master | StartFinishScope |
netcoreapp3.1 | 1.1μs | 5.99ns | 33.9ns | 0 | 0 | 0 | 640 B |
| master | StartFinishScope |
net472 | 1.07μs | 0.193ns | 0.747ns | 0.0911 | 0 | 0 | 602 B |
| master | StartFinishTwoScopes |
net6.0 | 1.78μs | 0.596ns | 2.31ns | 0 | 0 | 0 | 1.19 KB |
| master | StartFinishTwoScopes |
netcoreapp3.1 | 2.19μs | 11.8ns | 52.8ns | 0 | 0 | 0 | 1.19 KB |
| master | StartFinishTwoScopes |
net472 | 2.11μs | 1.68ns | 6.49ns | 0.17 | 0 | 0 | 1.08 KB |
| #7955 | StartFinishSpan |
net6.0 | 743ns | 3.92ns | 20ns | 0 | 0 | 0 | 520 B |
| #7955 | StartFinishSpan |
netcoreapp3.1 | 936ns | 4.83ns | 23.2ns | 0 | 0 | 0 | 520 B |
| #7955 | StartFinishSpan |
net472 | 885ns | 0.145ns | 0.561ns | 0.0799 | 0 | 0 | 522 B |
| #7955 | StartFinishScope |
net6.0 | 897ns | 1.86ns | 7.22ns | 0 | 0 | 0 | 640 B |
| #7955 | StartFinishScope |
netcoreapp3.1 | 1.13μs | 5.87ns | 27.5ns | 0 | 0 | 0 | 640 B |
| #7955 | StartFinishScope |
net472 | 1.09μs | 0.0998ns | 0.387ns | 0.0926 | 0 | 0 | 602 B |
| #7955 | StartFinishTwoScopes |
net6.0 | 1.75μs | 8.81ns | 41.3ns | 0 | 0 | 0 | 1.19 KB |
| #7955 | StartFinishTwoScopes |
netcoreapp3.1 | 2.18μs | 11ns | 49.2ns | 0 | 0 | 0 | 1.19 KB |
| #7955 | StartFinishTwoScopes |
net472 | 2.12μs | 2.24ns | 8.68ns | 0.171 | 0 | 0 | 1.08 KB |
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 | 1.05μs | 5.17ns | 22.5ns | 0 | 0 | 0 | 640 B |
| master | RunOnMethodBegin |
netcoreapp3.1 | 1.33μs | 4.1ns | 15.9ns | 0 | 0 | 0 | 640 B |
| master | RunOnMethodBegin |
net472 | 1.42μs | 0.633ns | 2.45ns | 0.0923 | 0 | 0 | 602 B |
| #7955 | RunOnMethodBegin |
net6.0 | 1.1μs | 3.91ns | 15.2ns | 0 | 0 | 0 | 640 B |
| #7955 | RunOnMethodBegin |
netcoreapp3.1 | 1.4μs | 6.7ns | 26.8ns | 0 | 0 | 0 | 640 B |
| #7955 | RunOnMethodBegin |
net472 | 1.42μs | 1.75ns | 6.55ns | 0.092 | 0 | 0 | 602 B |
NachoEchevarria
left a comment
There was a problem hiding this comment.
Nice catch! Thanks!
| using Datadog.Trace.SourceGenerators; | ||
| #if NETFRAMEWORK | ||
| using Datadog.Trace.VendoredMicrosoftCode.System.Runtime.CompilerServices.Unsafe; | ||
| #if NETCOREAPP3_1_OR_GREATER |
There was a problem hiding this comment.
oh hey I already handle this case in GlobalUsings.cs in #6726 😅
There was a problem hiding this comment.
I look forward to it being merged 😄
Summary of changes
Uses the vendored
System.Runtime.CompilerServices.Unsafeinstead of the BCL versionReason for change
The BCL version is not available in .NET Core 2.1. If it's not made available by some other means (e.g. by aspnetcore), then spans won't close correctly.
However, we were previously swallowing exceptions thrown when a
Scopeis disposed, so we had no visibility on this. I can't see a good reason to do that, so changed to log an exception instead (arguably, we could/should remove the try-catch entirely and catch in the integration, but this seems safer in the short term).Implementation details
Scope.Dispose()Test coverage
Confirmed the assembly ref has gone, and did manual testing with .NET Core 2.1, but as we don't support or test that directly, there's no explicit tests for it in CI
Other details
We should probably review our other swallowing instances, to make sure we're not missing anything else important