Enable CA1851 - Avoid multiple enumeration of collections#8341
Enable CA1851 - Avoid multiple enumeration of collections#8341andrewlock merged 1 commit intomasterfrom
CA1851 - Avoid multiple enumeration of collections#8341Conversation
BenchmarksBenchmark execution time: 2026-03-26 09:19:53 Comparing candidate commit 2bac6c8 in PR branch Found 9 performance improvements and 9 performance regressions! Performance is the same for 257 metrics, 13 unstable metrics.
|
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (8341) 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 (8341) - mean (72ms) : 70, 75
master - mean (72ms) : 70, 75
section Bailout
This PR (8341) - mean (76ms) : 75, 78
master - mean (76ms) : 75, 77
section CallTarget+Inlining+NGEN
This PR (8341) - mean (1,083ms) : 1028, 1139
master - mean (1,077ms) : 1028, 1127
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 (8341) - mean (114ms) : 110, 118
master - mean (113ms) : 108, 117
section Bailout
This PR (8341) - mean (115ms) : 112, 118
master - mean (114ms) : 111, 117
section CallTarget+Inlining+NGEN
This PR (8341) - mean (799ms) : 780, 818
master - mean (796ms) : 778, 813
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8341) - mean (100ms) : 97, 103
master - mean (99ms) : 95, 103
section Bailout
This PR (8341) - mean (102ms) : 99, 105
master - mean (100ms) : 97, 102
section CallTarget+Inlining+NGEN
This PR (8341) - mean (790ms) : 767, 814
master - mean (786ms) : 764, 808
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8341) - mean (98ms) : 95, 102
master - mean (99ms) : 94, 103
section Bailout
This PR (8341) - mean (100ms) : 98, 102
master - mean (99ms) : 97, 101
section CallTarget+Inlining+NGEN
This PR (8341) - mean (695ms) : 677, 714
master - mean (690ms) : 670, 710
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 (8341) - mean (195ms) : 191, 199
master - mean (194ms) : 190, 198
section Bailout
This PR (8341) - mean (198ms) : 194, 203
master - mean (197ms) : 195, 199
section CallTarget+Inlining+NGEN
This PR (8341) - mean (1,167ms) : 1098, 1235
master - mean (1,160ms) : 1104, 1215
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 (8341) - mean (277ms) : 273, 282
master - mean (277ms) : 272, 281
section Bailout
This PR (8341) - mean (279ms) : 274, 284
master - mean (278ms) : 273, 283
section CallTarget+Inlining+NGEN
This PR (8341) - mean (951ms) : 926, 976
master - mean (949ms) : 924, 975
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8341) - mean (273ms) : 267, 279
master - mean (272ms) : 267, 277
section Bailout
This PR (8341) - mean (274ms) : 265, 282
master - mean (272ms) : 267, 277
section CallTarget+Inlining+NGEN
This PR (8341) - mean (974ms) : 952, 996
master - mean (973ms) : 949, 996
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8341) - mean (270ms) : 265, 275
master - mean (271ms) : 266, 276
section Bailout
This PR (8341) - mean (270ms) : 266, 274
master - mean (269ms) : 265, 274
section CallTarget+Inlining+NGEN
This PR (8341) - mean (860ms) : 835, 884
master - mean (856ms) : 824, 887
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
25b4d09 to
b77ffa5
Compare
c5e641a to
0734582
Compare
b77ffa5 to
b6540ba
Compare
0734582 to
a65c4fb
Compare
b6540ba to
2bac6c8
Compare
Summary of changes
Enables
CA1851, fixes one violations, and ignores an existingReason for change
We want to enable this analayzer. Although, interestingly, there are cases where this won't touch, which we should potentially also have analyzers for. For example:
IEnumerable(could be call target, could be callsite aspects)If this isn't a materialized collection, this could be very expensive. Potentially, we should instead do:
ToList()on the parameterBut that also has risks 😅 So ideally... we just don't touch
IEnumerables 😅 🤷♂️Implementation details
StringModuleImpl, TheCount()call was to ensure we passaddDelimiterRanges: falseon the final iteration. Converting to a "manually implemented"foreachusing a "peek ahead" approach avoids the multiple enumerationsEncoder, it's all recursive and really hard to follow what the inputs are actually going to be here, so I just declared bankruptcy and put the#pragmain. If ASM want to fix it "properly" later, that's good, but don't want to block enabling the analyzer because of itTest coverage
Covered by existing
Other details
https://datadoghq.atlassian.net/browse/LANGPLAT-813
Stacked on
CA1861- Avoid constant arrays as arguments #8332CA1872- PreferConvert.ToHexStringoverBitConverter.ToString#8333CA1859- Use concrete types when possible #8335