Add "Types should be sealed" analyzer#7878
Conversation
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".
tracer/src/Datadog.Trace.Tools.Analyzers/SealedAnalyzer/SealedAnalyzer.cs
Show resolved
Hide resolved
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (7878) 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 (7878) - mean (76ms) : 69, 82
master - mean (76ms) : 71, 81
section Bailout
This PR (7878) - mean (81ms) : 75, 88
master - mean (80ms) : 75, 85
section CallTarget+Inlining+NGEN
This PR (7878) - mean (1,070ms) : 1005, 1136
master - mean (1,064ms) : 998, 1130
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 (7878) - mean (118ms) : 109, 127
master - mean (117ms) : 111, 122
section Bailout
This PR (7878) - mean (119ms) : 112, 126
master - mean (117ms) : 110, 125
section CallTarget+Inlining+NGEN
This PR (7878) - mean (754ms) : 716, 792
master - mean (758ms) : 718, 798
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7878) - mean (104ms) : 99, 110
master - mean (105ms) : 100, 110
section Bailout
This PR (7878) - mean (106ms) : 101, 112
master - mean (107ms) : 102, 112
section CallTarget+Inlining+NGEN
This PR (7878) - mean (709ms) : 676, 742
master - mean (703ms) : 672, 734
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7878) - mean (103ms) : 97, 110
master - mean (103ms) : 95, 110
section Bailout
This PR (7878) - mean (105ms) : 99, 111
master - mean (107ms) : 99, 115
section CallTarget+Inlining+NGEN
This PR (7878) - mean (679ms) : 642, 716
master - mean (684ms) : 642, 725
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 (7878) - mean (194ms) : 188, 199
master - mean (193ms) : 189, 197
section Bailout
This PR (7878) - mean (197ms) : 195, 199
master - mean (197ms) : 194, 199
section CallTarget+Inlining+NGEN
This PR (7878) - mean (1,117ms) : 1055, 1179
master - mean (1,116ms) : 1062, 1170
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 (7878) - mean (277ms) : 272, 282
master - mean (277ms) : 271, 283
section Bailout
This PR (7878) - mean (278ms) : 273, 282
master - mean (277ms) : 274, 281
section CallTarget+Inlining+NGEN
This PR (7878) - mean (902ms) : 867, 937
master - mean (911ms) : 865, 957
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7878) - mean (270ms) : 266, 274
master - mean (271ms) : 267, 275
section Bailout
This PR (7878) - mean (271ms) : 265, 276
master - mean (270ms) : 267, 274
section CallTarget+Inlining+NGEN
This PR (7878) - mean (886ms) : 846, 926
master - mean (885ms) : 845, 925
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7878) - mean (270ms) : 265, 275
master - mean (269ms) : 265, 272
section Bailout
This PR (7878) - mean (269ms) : 266, 272
master - mean (270ms) : 267, 273
section CallTarget+Inlining+NGEN
This PR (7878) - mean (829ms) : 810, 848
master - mean (827ms) : 806, 848
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
BenchmarksBenchmarks Report for benchmark platform 🐌Benchmarks for #7878 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 ✔️ Fewer allocations 🎉
|
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.ActivityBenchmark.StartStopWithChild‑net472 | 6 KB | 5.93 KB | -73 B | -1.22% |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | StartStopWithChild |
net6.0 | 10.5μs | 56.6ns | 330ns | 0 | 0 | 0 | 5.5 KB |
| master | StartStopWithChild |
netcoreapp3.1 | 13.5μs | 68.5ns | 306ns | 0 | 0 | 0 | 5.72 KB |
| master | StartStopWithChild |
net472 | 21.8μs | 79.6ns | 298ns | 0.87 | 0.217 | 0 | 6 KB |
| #7878 | StartStopWithChild |
net6.0 | 11μs | 60.7ns | 364ns | 0 | 0 | 0 | 5.52 KB |
| #7878 | StartStopWithChild |
netcoreapp3.1 | 13.7μs | 68.9ns | 292ns | 0 | 0 | 0 | 5.71 KB |
| #7878 | StartStopWithChild |
net472 | 22.2μs | 98.9ns | 370ns | 1.03 | 0.309 | 0.103 | 5.93 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 | 1.25ms | 206ns | 770ns | 0 | 0 | 0 | 2.7 KB |
| master | WriteAndFlushEnrichedTraces |
netcoreapp3.1 | 1.39ms | 79.6ns | 308ns | 0 | 0 | 0 | 2.7 KB |
| master | WriteAndFlushEnrichedTraces |
net472 | 1.76ms | 1.26μs | 4.86μs | 0 | 0 | 0 | 3.26 KB |
| #7878 | WriteAndFlushEnrichedTraces |
net6.0 | 1.26ms | 175ns | 632ns | 0 | 0 | 0 | 2.7 KB |
| #7878 | WriteAndFlushEnrichedTraces |
netcoreapp3.1 | 1.38ms | 148ns | 553ns | 0 | 0 | 0 | 2.7 KB |
| #7878 | WriteAndFlushEnrichedTraces |
net472 | 1.73ms | 3.89μs | 15.1μs | 0 | 0 | 0 | 3.26 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.09μs | 6.08ns | 39.9ns | 0 | 0 | 0 | 1.22 KB |
| master | AllCycleSimpleBody |
netcoreapp3.1 | 1.38μs | 7.76ns | 53.2ns | 0 | 0 | 0 | 1.2 KB |
| master | AllCycleSimpleBody |
net472 | 1μs | 0.238ns | 0.922ns | 0.191 | 0 | 0 | 1.23 KB |
| master | AllCycleMoreComplexBody |
net6.0 | 7.32μs | 36.7ns | 168ns | 0 | 0 | 0 | 4.72 KB |
| master | AllCycleMoreComplexBody |
netcoreapp3.1 | 8.88μs | 46.5ns | 237ns | 0 | 0 | 0 | 4.62 KB |
| master | AllCycleMoreComplexBody |
net472 | 7.7μs | 4.23ns | 16.4ns | 0.731 | 0 | 0 | 4.74 KB |
| master | ObjectExtractorSimpleBody |
net6.0 | 317ns | 0.0977ns | 0.366ns | 0 | 0 | 0 | 280 B |
| master | ObjectExtractorSimpleBody |
netcoreapp3.1 | 395ns | 2.17ns | 13.4ns | 0 | 0 | 0 | 272 B |
| master | ObjectExtractorSimpleBody |
net472 | 300ns | 0.0108ns | 0.0402ns | 0.0439 | 0 | 0 | 281 B |
| master | ObjectExtractorMoreComplexBody |
net6.0 | 6.34μs | 29.4ns | 118ns | 0 | 0 | 0 | 3.78 KB |
| master | ObjectExtractorMoreComplexBody |
netcoreapp3.1 | 7.82μs | 36.6ns | 142ns | 0 | 0 | 0 | 3.69 KB |
| master | ObjectExtractorMoreComplexBody |
net472 | 6.68μs | 2.21ns | 8.56ns | 0.602 | 0 | 0 | 3.8 KB |
| #7878 | AllCycleSimpleBody |
net6.0 | 1.06μs | 6.17ns | 52.3ns | 0 | 0 | 0 | 1.22 KB |
| #7878 | AllCycleSimpleBody |
netcoreapp3.1 | 1.43μs | 7.61ns | 39.5ns | 0 | 0 | 0 | 1.2 KB |
| #7878 | AllCycleSimpleBody |
net472 | 1.01μs | 0.259ns | 1.01ns | 0.192 | 0 | 0 | 1.23 KB |
| #7878 | AllCycleMoreComplexBody |
net6.0 | 7.12μs | 37.9ns | 204ns | 0 | 0 | 0 | 4.72 KB |
| #7878 | AllCycleMoreComplexBody |
netcoreapp3.1 | 9.17μs | 45.6ns | 199ns | 0 | 0 | 0 | 4.62 KB |
| #7878 | AllCycleMoreComplexBody |
net472 | 7.7μs | 3.51ns | 13.6ns | 0.733 | 0 | 0 | 4.74 KB |
| #7878 | ObjectExtractorSimpleBody |
net6.0 | 308ns | 1.78ns | 13.8ns | 0 | 0 | 0 | 280 B |
| #7878 | ObjectExtractorSimpleBody |
netcoreapp3.1 | 416ns | 2.04ns | 8.4ns | 0 | 0 | 0 | 272 B |
| #7878 | ObjectExtractorSimpleBody |
net472 | 309ns | 0.0817ns | 0.316ns | 0.0435 | 0 | 0 | 281 B |
| #7878 | ObjectExtractorMoreComplexBody |
net6.0 | 6.3μs | 29.4ns | 114ns | 0 | 0 | 0 | 3.78 KB |
| #7878 | ObjectExtractorMoreComplexBody |
netcoreapp3.1 | 7.83μs | 31ns | 120ns | 0 | 0 | 0 | 3.69 KB |
| #7878 | ObjectExtractorMoreComplexBody |
net472 | 6.8μs | 5.41ns | 20.9ns | 0.579 | 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 | 76.3μs | 299ns | 1.12μs | 0 | 0 | 0 | 32.4 KB |
| master | EncodeArgs |
netcoreapp3.1 | 97.9μs | 379ns | 1.47μs | 0 | 0 | 0 | 32.4 KB |
| master | EncodeArgs |
net472 | 108μs | 14ns | 54.2ns | 4.87 | 0 | 0 | 32.5 KB |
| master | EncodeLegacyArgs |
net6.0 | 142μs | 34.7ns | 134ns | 0 | 0 | 0 | 2.14 KB |
| master | EncodeLegacyArgs |
netcoreapp3.1 | 198μs | 26.2ns | 98.1ns | 0 | 0 | 0 | 2.14 KB |
| master | EncodeLegacyArgs |
net472 | 263μs | 42.9ns | 166ns | 0 | 0 | 0 | 2.14 KB |
| #7878 | EncodeArgs |
net6.0 | 75.7μs | 354ns | 1.41μs | 0 | 0 | 0 | 32.4 KB |
| #7878 | EncodeArgs |
netcoreapp3.1 | 96.7μs | 269ns | 1.04μs | 0 | 0 | 0 | 32.4 KB |
| #7878 | EncodeArgs |
net472 | 108μs | 34.4ns | 133ns | 4.88 | 0 | 0 | 32.5 KB |
| #7878 | EncodeLegacyArgs |
net6.0 | 145μs | 15ns | 56.2ns | 0 | 0 | 0 | 2.14 KB |
| #7878 | EncodeLegacyArgs |
netcoreapp3.1 | 200μs | 203ns | 787ns | 0 | 0 | 0 | 2.14 KB |
| #7878 | EncodeLegacyArgs |
net472 | 264μs | 30.6ns | 114ns | 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 | 427μs | 2.14μs | 9.31μs | 0 | 0 | 0 | 4.55 KB |
| master | RunWafRealisticBenchmark |
netcoreapp3.1 | 464μs | 1.58μs | 5.9μs | 0 | 0 | 0 | 4.48 KB |
| master | RunWafRealisticBenchmark |
net472 | 496μs | 231ns | 834ns | 0 | 0 | 0 | 0 b |
| master | RunWafRealisticBenchmarkWithAttack |
net6.0 | 319μs | 1.47μs | 5.49μs | 0 | 0 | 0 | 2.24 KB |
| master | RunWafRealisticBenchmarkWithAttack |
netcoreapp3.1 | 347μs | 1.93μs | 13.6μs | 0 | 0 | 0 | 2.22 KB |
| master | RunWafRealisticBenchmarkWithAttack |
net472 | 368μs | 493ns | 1.78μs | 0 | 0 | 0 | 0 b |
| #7878 | RunWafRealisticBenchmark |
net6.0 | 430μs | 1.69μs | 6.09μs | 0 | 0 | 0 | 4.55 KB |
| #7878 | RunWafRealisticBenchmark |
netcoreapp3.1 | 474μs | 2.7μs | 25μs | 0 | 0 | 0 | 4.48 KB |
| #7878 | RunWafRealisticBenchmark |
net472 | 500μs | 401ns | 1.5μs | 0 | 0 | 0 | 0 b |
| #7878 | RunWafRealisticBenchmarkWithAttack |
net6.0 | 314μs | 1.41μs | 5.07μs | 0 | 0 | 0 | 2.24 KB |
| #7878 | RunWafRealisticBenchmarkWithAttack |
netcoreapp3.1 | 355μs | 2.97μs | 27.9μs | 0 | 0 | 0 | 2.22 KB |
| #7878 | RunWafRealisticBenchmarkWithAttack |
net472 | 368μs | 472ns | 1.7μs | 0 | 0 | 0 | 0 b |
Benchmarks.Trace.AspNetCoreBenchmark - Unknown 🤷 Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | SendRequest |
net6.0 | 84μs | 75.5ns | 292ns | 0 | 0 | 0 | 19.03 KB |
| master | SendRequest |
netcoreapp3.1 | 97μs | 364ns | 2.03μs | 0 | 0 | 0 | 21.25 KB |
| master | SendRequest |
net472 | 0ns | 0ns | 0ns | 0 | 0 | 0 | 0 b |
| #7878 | SendRequest |
net6.0 | 84.9μs | 85.4ns | 308ns | 0 | 0 | 0 | 19.04 KB |
| #7878 | SendRequest |
netcoreapp3.1 | 98.6μs | 390ns | 2.02μs | 0 | 0 | 0 | 21.25 KB |
| #7878 | SendRequest |
net472 | 0ns | 0ns | 0ns | 0 | 0 | 0 | 0 b |
Benchmarks.Trace.CharSliceBenchmark - Faster 🎉 Same allocations ✔️
Faster 🎉 in #7878
Benchmark
base/diff
Base Median (ns)
Diff Median (ns)
Modality
Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice‑netcoreapp3.1
1.801
3,928,850.00
2,181,300.00
| Benchmark | base/diff | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice‑netcoreapp3.1 | 1.801 | 3,928,850.00 | 2,181,300.00 |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | OriginalCharSlice |
net6.0 | 1.91ms | 1.86μs | 7.21μs | 0 | 0 | 0 | 640 KB |
| master | OriginalCharSlice |
netcoreapp3.1 | 3.93ms | 877ns | 3.39μs | 0 | 0 | 0 | 640.05 KB |
| master | OriginalCharSlice |
net472 | 2.58ms | 442ns | 1.65μs | 0 | 0 | 0 | 638.98 KB |
| master | OptimizedCharSlice |
net6.0 | 1.45ms | 3.25μs | 12.6μs | 0 | 0 | 0 | 0 b |
| master | OptimizedCharSlice |
netcoreapp3.1 | 2.73ms | 996ns | 3.45μs | 0 | 0 | 0 | 0 b |
| master | OptimizedCharSlice |
net472 | 1.95ms | 957ns | 3.58μs | 0 | 0 | 0 | 0 b |
| master | OptimizedCharSliceWithPool |
net6.0 | 1.05ms | 691ns | 2.68μs | 0 | 0 | 0 | 0 b |
| master | OptimizedCharSliceWithPool |
netcoreapp3.1 | 1.85ms | 1.99μs | 7.7μs | 0 | 0 | 0 | 0 b |
| master | OptimizedCharSliceWithPool |
net472 | 1.16ms | 710ns | 2.75μs | 0 | 0 | 0 | 0 b |
| #7878 | OriginalCharSlice |
net6.0 | 1.94ms | 1.96μs | 7.08μs | 0 | 0 | 0 | 640 KB |
| #7878 | OriginalCharSlice |
netcoreapp3.1 | 2.18ms | 6.59μs | 41.7μs | 0 | 0 | 0 | 640 KB |
| #7878 | OriginalCharSlice |
net472 | 2.71ms | 756ns | 2.93μs | 0 | 0 | 0 | 638.98 KB |
| #7878 | OptimizedCharSlice |
net6.0 | 1.48ms | 327ns | 1.18μs | 0 | 0 | 0 | 0 b |
| #7878 | OptimizedCharSlice |
netcoreapp3.1 | 2.78ms | 558ns | 1.93μs | 0 | 0 | 0 | 0 b |
| #7878 | OptimizedCharSlice |
net472 | 1.89ms | 927ns | 3.34μs | 0 | 0 | 0 | 0 b |
| #7878 | OptimizedCharSliceWithPool |
net6.0 | 1.02ms | 1.1μs | 3.8μs | 0 | 0 | 0 | 0 b |
| #7878 | OptimizedCharSliceWithPool |
netcoreapp3.1 | 1.86ms | 1.87μs | 7.24μs | 0 | 0 | 0 | 0 b |
| #7878 | OptimizedCharSliceWithPool |
net472 | 1.15ms | 374ns | 1.35μs | 0 | 0 | 0 | 0 b |
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ More allocations ⚠️
More allocations ⚠️ in #7878
Benchmark
Base Allocated
Diff Allocated
Change
Change %
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net472
55.79 KB
56.87 KB
1.08 KB
1.93%
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces‑net472 | 55.79 KB | 56.87 KB | 1.08 KB | 1.93% |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | WriteAndFlushEnrichedTraces |
net6.0 | 761μs | 1.44μs | 5.57μs | 0 | 0 | 0 | 41.68 KB |
| master | WriteAndFlushEnrichedTraces |
netcoreapp3.1 | 700μs | 3.64μs | 17.8μs | 0 | 0 | 0 | 41.8 KB |
| master | WriteAndFlushEnrichedTraces |
net472 | 892μs | 3.52μs | 13.6μs | 4.46 | 0 | 0 | 55.79 KB |
| #7878 | WriteAndFlushEnrichedTraces |
net6.0 | 751μs | 4.38μs | 35.1μs | 0 | 0 | 0 | 41.73 KB |
| #7878 | WriteAndFlushEnrichedTraces |
netcoreapp3.1 | 729μs | 4.26μs | 40μs | 0 | 0 | 0 | 41.78 KB |
| #7878 | WriteAndFlushEnrichedTraces |
net472 | 954μs | 5.05μs | 27.2μs | 8.93 | 4.46 | 0 | 56.87 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.86μs | 7.27ns | 28.2ns | 0 | 0 | 0 | 1.02 KB |
| master | ExecuteNonQuery |
netcoreapp3.1 | 2.57μs | 6.77ns | 26.2ns | 0 | 0 | 0 | 1.02 KB |
| master | ExecuteNonQuery |
net472 | 2.79μs | 3.48ns | 13.5ns | 0.15 | 0 | 0 | 987 B |
| #7878 | ExecuteNonQuery |
net6.0 | 1.98μs | 2.4ns | 9.3ns | 0 | 0 | 0 | 1.02 KB |
| #7878 | ExecuteNonQuery |
netcoreapp3.1 | 2.54μs | 6.09ns | 23.6ns | 0 | 0 | 0 | 1.02 KB |
| #7878 | ExecuteNonQuery |
net472 | 2.69μs | 1.1ns | 3.81ns | 0.149 | 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.67μs | 8.33ns | 36.3ns | 0 | 0 | 0 | 1.01 KB |
| master | CallElasticsearch |
netcoreapp3.1 | 2.27μs | 9.56ns | 37ns | 0 | 0 | 0 | 1.02 KB |
| master | CallElasticsearch |
net472 | 3.4μs | 3.1ns | 11.6ns | 0.154 | 0 | 0 | 1.01 KB |
| master | CallElasticsearchAsync |
net6.0 | 1.76μs | 8.62ns | 35.5ns | 0 | 0 | 0 | 984 B |
| master | CallElasticsearchAsync |
netcoreapp3.1 | 2.46μs | 10.8ns | 41.9ns | 0 | 0 | 0 | 1.07 KB |
| master | CallElasticsearchAsync |
net472 | 3.55μs | 1.58ns | 5.9ns | 0.159 | 0 | 0 | 1.07 KB |
| #7878 | CallElasticsearch |
net6.0 | 1.72μs | 2.5ns | 9.69ns | 0 | 0 | 0 | 1.01 KB |
| #7878 | CallElasticsearch |
netcoreapp3.1 | 2.23μs | 10.9ns | 46.4ns | 0 | 0 | 0 | 1.02 KB |
| #7878 | CallElasticsearch |
net472 | 3.53μs | 2.15ns | 8.32ns | 0.158 | 0 | 0 | 1.01 KB |
| #7878 | CallElasticsearchAsync |
net6.0 | 1.75μs | 6.77ns | 26.2ns | 0 | 0 | 0 | 984 B |
| #7878 | CallElasticsearchAsync |
netcoreapp3.1 | 2.72μs | 9.45ns | 36.6ns | 0 | 0 | 0 | 1.07 KB |
| #7878 | CallElasticsearchAsync |
net472 | 3.6μs | 3.85ns | 14.9ns | 0.163 | 0 | 0 | 1.07 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.91μs | 9.42ns | 38.8ns | 0 | 0 | 0 | 953 B |
| master | ExecuteAsync |
netcoreapp3.1 | 2.5μs | 7.36ns | 28.5ns | 0 | 0 | 0 | 952 B |
| master | ExecuteAsync |
net472 | 2.63μs | 2.29ns | 8.86ns | 0.144 | 0 | 0 | 915 B |
| #7878 | ExecuteAsync |
net6.0 | 1.88μs | 8.98ns | 37ns | 0 | 0 | 0 | 952 B |
| #7878 | ExecuteAsync |
netcoreapp3.1 | 2.38μs | 8.47ns | 32.8ns | 0 | 0 | 0 | 952 B |
| #7878 | ExecuteAsync |
net472 | 2.68μs | 1.48ns | 5.72ns | 0.134 | 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 | 6.89μs | 23.4ns | 90.8ns | 0 | 0 | 0 | 2.34 KB |
| master | SendAsync |
netcoreapp3.1 | 8.46μs | 24.9ns | 89.7ns | 0 | 0 | 0 | 2.89 KB |
| master | SendAsync |
net472 | 12.2μs | 9.27ns | 34.7ns | 0.489 | 0 | 0 | 3.14 KB |
| #7878 | SendAsync |
net6.0 | 6.97μs | 16.4ns | 63.7ns | 0 | 0 | 0 | 2.34 KB |
| #7878 | SendAsync |
netcoreapp3.1 | 8.16μs | 27.4ns | 106ns | 0 | 0 | 0 | 2.89 KB |
| #7878 | SendAsync |
net472 | 12.3μs | 10.1ns | 39.3ns | 0.493 | 0 | 0 | 3.14 KB |
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ More allocations ⚠️
More allocations ⚠️ in #7878
Benchmark
Base Allocated
Diff Allocated
Change
Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1
257.52 KB
272.67 KB
15.15 KB
5.88%
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1 | 257.52 KB | 272.67 KB | 15.15 KB | 5.88% |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | StringConcatBenchmark |
net6.0 | 44.9μs | 266ns | 2.39μs | 0 | 0 | 0 | 42.51 KB |
| master | StringConcatBenchmark |
netcoreapp3.1 | 50.7μs | 327ns | 3.09μs | 0 | 0 | 0 | 42.54 KB |
| master | StringConcatBenchmark |
net472 | 56.4μs | 290ns | 1.3μs | 0 | 0 | 0 | 49.15 KB |
| master | StringConcatAspectBenchmark |
net6.0 | 485μs | 2.34μs | 9.37μs | 0 | 0 | 0 | 273.92 KB |
| master | StringConcatAspectBenchmark |
netcoreapp3.1 | 434μs | 5.13μs | 50.3μs | 0 | 0 | 0 | 257.52 KB |
| master | StringConcatAspectBenchmark |
net472 | 411μs | 2.37μs | 18.3μs | 0 | 0 | 0 | 270.34 KB |
| #7878 | StringConcatBenchmark |
net6.0 | 44.4μs | 255ns | 1.79μs | 0 | 0 | 0 | 42.51 KB |
| #7878 | StringConcatBenchmark |
netcoreapp3.1 | 48.3μs | 262ns | 1.33μs | 0 | 0 | 0 | 42.54 KB |
| #7878 | StringConcatBenchmark |
net472 | 58.8μs | 291ns | 1.3μs | 0 | 0 | 0 | 49.15 KB |
| #7878 | StringConcatAspectBenchmark |
net6.0 | 474μs | 2.09μs | 10.2μs | 0 | 0 | 0 | 273.98 KB |
| #7878 | StringConcatAspectBenchmark |
netcoreapp3.1 | 475μs | 6.94μs | 68.7μs | 0 | 0 | 0 | 272.67 KB |
| #7878 | StringConcatAspectBenchmark |
net472 | 417μs | 2.3μs | 13.4μ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.71μs | 13.2ns | 57.7ns | 0 | 0 | 0 | 1.69 KB |
| master | EnrichedLog |
netcoreapp3.1 | 3.53μs | 4.87ns | 18.9ns | 0 | 0 | 0 | 1.7 KB |
| master | EnrichedLog |
net472 | 3.85μs | 2.27ns | 8.81ns | 0.251 | 0 | 0 | 1.6 KB |
| #7878 | EnrichedLog |
net6.0 | 2.66μs | 2.13ns | 8.27ns | 0 | 0 | 0 | 1.69 KB |
| #7878 | EnrichedLog |
netcoreapp3.1 | 3.54μs | 16.8ns | 67.3ns | 0 | 0 | 0 | 1.7 KB |
| #7878 | EnrichedLog |
net472 | 3.82μs | 2.22ns | 8.31ns | 0.248 | 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 | 124μs | 53.6ns | 186ns | 0 | 0 | 0 | 4.31 KB |
| master | EnrichedLog |
netcoreapp3.1 | 129μs | 199ns | 718ns | 0 | 0 | 0 | 4.31 KB |
| master | EnrichedLog |
net472 | 168μs | 150ns | 580ns | 0 | 0 | 0 | 4.51 KB |
| #7878 | EnrichedLog |
net6.0 | 124μs | 385ns | 1.44μs | 0 | 0 | 0 | 4.31 KB |
| #7878 | EnrichedLog |
netcoreapp3.1 | 129μs | 84.4ns | 316ns | 0 | 0 | 0 | 4.31 KB |
| #7878 | EnrichedLog |
net472 | 167μs | 86ns | 333ns | 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 | 5.15μs | 20.2ns | 78.2ns | 0 | 0 | 0 | 2.24 KB |
| master | EnrichedLog |
netcoreapp3.1 | 6.95μs | 20.3ns | 78.6ns | 0 | 0 | 0 | 2.26 KB |
| master | EnrichedLog |
net472 | 7.55μs | 8.84ns | 34.2ns | 0.3 | 0 | 0 | 2.05 KB |
| #7878 | EnrichedLog |
net6.0 | 5.1μs | 21.9ns | 84.9ns | 0 | 0 | 0 | 2.24 KB |
| #7878 | EnrichedLog |
netcoreapp3.1 | 6.83μs | 22.2ns | 86.1ns | 0 | 0 | 0 | 2.26 KB |
| #7878 | EnrichedLog |
net472 | 7.69μs | 8.3ns | 32.2ns | 0.309 | 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 | 2μs | 0.614ns | 2.38ns | 0 | 0 | 0 | 1.18 KB |
| master | SendReceive |
netcoreapp3.1 | 2.65μs | 12.8ns | 54.2ns | 0 | 0 | 0 | 1.19 KB |
| master | SendReceive |
net472 | 2.95μs | 2.31ns | 8.94ns | 0.177 | 0 | 0 | 1.17 KB |
| #7878 | SendReceive |
net6.0 | 2μs | 7.96ns | 30.8ns | 0 | 0 | 0 | 1.18 KB |
| #7878 | SendReceive |
netcoreapp3.1 | 2.78μs | 5.4ns | 20.9ns | 0 | 0 | 0 | 1.19 KB |
| #7878 | SendReceive |
net472 | 3.05μs | 7.14ns | 27.6ns | 0.179 | 0 | 0 | 1.17 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.34μs | 4.31ns | 16.7ns | 0 | 0 | 0 | 1.58 KB |
| master | EnrichedLog |
netcoreapp3.1 | 5.44μs | 16.8ns | 65.1ns | 0 | 0 | 0 | 1.63 KB |
| master | EnrichedLog |
net472 | 6.59μs | 11.4ns | 44ns | 0.294 | 0 | 0 | 2.03 KB |
| #7878 | EnrichedLog |
net6.0 | 4.59μs | 9.11ns | 34.1ns | 0 | 0 | 0 | 1.58 KB |
| #7878 | EnrichedLog |
netcoreapp3.1 | 5.75μs | 16.8ns | 65.1ns | 0 | 0 | 0 | 1.63 KB |
| #7878 | EnrichedLog |
net472 | 6.6μs | 9.89ns | 37ns | 0.294 | 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 | 798ns | 4.05ns | 17.7ns | 0 | 0 | 0 | 576 B |
| master | StartFinishSpan |
netcoreapp3.1 | 975ns | 5.14ns | 21.8ns | 0 | 0 | 0 | 576 B |
| master | StartFinishSpan |
net472 | 902ns | 0.0976ns | 0.365ns | 0.0907 | 0 | 0 | 578 B |
| master | StartFinishScope |
net6.0 | 946ns | 3.67ns | 13.7ns | 0 | 0 | 0 | 696 B |
| master | StartFinishScope |
netcoreapp3.1 | 1.16μs | 5.79ns | 24.6ns | 0 | 0 | 0 | 696 B |
| master | StartFinishScope |
net472 | 1.12μs | 0.553ns | 2.14ns | 0.101 | 0 | 0 | 658 B |
| master | StartFinishTwoScopes |
net6.0 | 1.78μs | 2.92ns | 11.3ns | 0 | 0 | 0 | 1.19 KB |
| master | StartFinishTwoScopes |
netcoreapp3.1 | 2.19μs | 11.3ns | 55.4ns | 0 | 0 | 0 | 1.19 KB |
| master | StartFinishTwoScopes |
net472 | 2.17μs | 2.55ns | 9.87ns | 0.162 | 0 | 0 | 1.08 KB |
| #7878 | StartFinishSpan |
net6.0 | 785ns | 3.85ns | 15.4ns | 0 | 0 | 0 | 576 B |
| #7878 | StartFinishSpan |
netcoreapp3.1 | 964ns | 4.77ns | 20.8ns | 0 | 0 | 0 | 576 B |
| #7878 | StartFinishSpan |
net472 | 908ns | 2.38ns | 9.22ns | 0.0899 | 0 | 0 | 578 B |
| #7878 | StartFinishScope |
net6.0 | 950ns | 4.83ns | 23.1ns | 0 | 0 | 0 | 696 B |
| #7878 | StartFinishScope |
netcoreapp3.1 | 1.14μs | 5.94ns | 29.1ns | 0 | 0 | 0 | 697 B |
| #7878 | StartFinishScope |
net472 | 1.13μs | 2.9ns | 11.2ns | 0.102 | 0 | 0 | 658 B |
| #7878 | StartFinishTwoScopes |
net6.0 | 1.74μs | 8.81ns | 40.4ns | 0 | 0 | 0 | 1.19 KB |
| #7878 | StartFinishTwoScopes |
netcoreapp3.1 | 2.19μs | 10.9ns | 46.2ns | 0 | 0 | 0 | 1.19 KB |
| #7878 | StartFinishTwoScopes |
net472 | 2.14μs | 1.79ns | 6.92ns | 0.16 | 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.12μs | 5.98ns | 31.6ns | 0 | 0 | 0 | 696 B |
| master | RunOnMethodBegin |
netcoreapp3.1 | 1.42μs | 7.24ns | 33.2ns | 0 | 0 | 0 | 696 B |
| master | RunOnMethodBegin |
net472 | 1.49μs | 3.84ns | 14.9ns | 0.098 | 0 | 0 | 658 B |
| #7878 | RunOnMethodBegin |
net6.0 | 1.07μs | 4.88ns | 18.9ns | 0 | 0 | 0 | 696 B |
| #7878 | RunOnMethodBegin |
netcoreapp3.1 | 1.44μs | 1.73ns | 6.48ns | 0 | 0 | 0 | 696 B |
| #7878 | RunOnMethodBegin |
net472 | 1.49μs | 5.09ns | 19.7ns | 0.0979 | 0 | 0 | 658 B |
222d5ac to
6f7e4ff
Compare
## Summary of changes - Upgrades the `SealedAnalyzer` added in #7878 from `info` to `warning` for specific projects - Fix all the errors it flagged ## Reason for change As described in `#7878`, making types `sealed` can have performance benefits. It's basically a free small perf bump, and there's not _really_ any downsides. ## Implementation details After writing the analyzer, I got claude code to fix all the violations. Annoyingly, `dotnet format` doesn't seem to work with this analyzer because it's a "compilation end" analyzer. Then I went through all the changes and confirmed they're valid. I also changed a bunch to `static` where they were stateless and effectively _should_ have been static. > I initially made all the integrations and aspects `static` instead of `sealed`, but then realised the integration are used as generic arguments, and I suspect that's not allowed at runtime I have written some comments on the PR for places where we had to explicitly ignore, but GitHub can't handle it, so here's some others 😅 - `Tracer` - had to not marked this sealed, because we derive from it in tests 🙁 This one is very annoying, I may try to fix in a subsequent PR. - `DirectSubmissionLogSink` - we were deriving from this in tests so that we could call a protected method, so just added a way to call that instead. - `PerformanceCountersListener` - we derive from this in tests. ## Test coverage As long as everything passes, we should be good 🤞 ## Other details Stacked on - #7878 https://datadoghq.atlassian.net/browse/LANGPLAT-813
Summary of changes
Adds an analyzer that checks that types are sealed (where appropriate)
Reason for change
There are numerous performance benefits to sealing types (as per this issue):
Example
results in
is/astype checks for the type can be done more efficiently, as it only needs to compare the type itself rather than account for a potential hierarchy.Example
results in:
Example
results in
Example
results in
And there's not really a good reason not to in most cases.
The .NET SDK includes such an analyzer, but it's not quite right for our purposes.:
internaltypes, whereas we should apply it topublictoo (seeing as our "public" API isn't actually any different from an internal API)In some cases we can't be sealed, e.g. duck typesSubsequently realised that's not the case, we always create "wrapper" duck types around an instance, even with reverse duck typing, so whether the instance is sealed doesn't matterImplementation details
SealInternalTypesanalyzer from the .NET SDK, and tweaked itinfofor now, so that we can opt in certain projects as we see fit.Test coverage
Added unit tests in this PR, and I can confirm it works as expected locally
Other details
I'll make a follow up PR to enable this diagnostic in Datadog.Trace and select other projects
https://datadoghq.atlassian.net/browse/LANGPLAT-813