Don't use global statics where possible
Summary of changes
- Fix a nullability attribute
- Pass in an
Iastinstance in favour of using staticIast.Iast.Instance
Reason for change
In AspNetCoreDiagnosticObserver, we explicitly pass in an Iast instance, primarily for testing purposes, but then we're "accidentally" accessing the static instance in the pipeline helper, defeating the purpose for testing
Implementation details
- Pass in
Iastwhere possible instead of accessing global state - Add
?to property which can (and sometimes will) benull
Test coverage
Covered by existing
Other details
Noticed while working on other things
Execution-Time Benchmarks Report :stopwatch:
Execution-time results for samples comparing This PR (7939) and master.
✅ No regressions detected - check the details below
Full Metrics Comparison
FakeDbCommand
| Metric | Master (Mean ± 95% CI) | Current (Mean ± 95% CI) | Change | Status |
|---|---|---|---|---|
| .NET Framework 4.8 - Baseline | ||||
| duration | 74.72 ± (74.84 - 75.55) ms | 73.82 ± (73.89 - 74.66) ms | -1.2% | ✅ |
| .NET Framework 4.8 - Bailout | ||||
| duration | 78.59 ± (78.58 - 79.22) ms | 78.75 ± (78.81 - 79.59) ms | +0.2% | ✅⬆️ |
| .NET Framework 4.8 - CallTarget+Inlining+NGEN | ||||
| duration | 1057.65 ± (1060.61 - 1067.66) ms | 1063.48 ± (1064.02 - 1073.09) ms | +0.6% | ✅⬆️ |
| .NET Core 3.1 - Baseline | ||||
| process.internal_duration_ms | 22.78 ± (22.70 - 22.85) ms | 22.84 ± (22.78 - 22.90) ms | +0.3% | ✅⬆️ |
| process.time_to_main_ms | 85.84 ± (85.53 - 86.14) ms | 86.38 ± (86.03 - 86.74) ms | +0.6% | ✅⬆️ |
| runtime.dotnet.exceptions.count | 0 ± (0 - 0) | 0 ± (0 - 0) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 10.91 ± (10.91 - 10.91) MB | 10.91 ± (10.90 - 10.91) MB | -0.0% | ✅ |
| runtime.dotnet.threads.count | 12 ± (12 - 12) | 12 ± (12 - 12) | +0.0% | ✅ |
| .NET Core 3.1 - Bailout | ||||
| process.internal_duration_ms | 22.89 ± (22.83 - 22.96) ms | 22.80 ± (22.74 - 22.85) ms | -0.4% | ✅ |
| process.time_to_main_ms | 88.27 ± (87.92 - 88.62) ms | 88.15 ± (87.79 - 88.52) ms | -0.1% | ✅ |
| runtime.dotnet.exceptions.count | 0 ± (0 - 0) | 0 ± (0 - 0) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 10.96 ± (10.96 - 10.96) MB | 10.96 ± (10.95 - 10.96) MB | -0.0% | ✅ |
| runtime.dotnet.threads.count | 13 ± (13 - 13) | 13 ± (13 - 13) | +0.0% | ✅ |
| .NET Core 3.1 - CallTarget+Inlining+NGEN | ||||
| process.internal_duration_ms | 222.25 ± (220.86 - 223.65) ms | 221.76 ± (220.30 - 223.22) ms | -0.2% | ✅ |
| process.time_to_main_ms | 502.83 ± (501.75 - 503.91) ms | 504.26 ± (502.83 - 505.69) ms | +0.3% | ✅⬆️ |
| runtime.dotnet.exceptions.count | 0 ± (0 - 0) | 0 ± (0 - 0) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 48.03 ± (48.01 - 48.06) MB | 48.07 ± (48.05 - 48.09) MB | +0.1% | ✅⬆️ |
| runtime.dotnet.threads.count | 28 ± (28 - 28) | 28 ± (28 - 28) | -0.4% | ✅ |
| .NET 6 - Baseline | ||||
| process.internal_duration_ms | 21.51 ± (21.45 - 21.56) ms | 21.70 ± (21.62 - 21.78) ms | +0.9% | ✅⬆️ |
| process.time_to_main_ms | 74.51 ± (74.21 - 74.80) ms | 75.60 ± (75.20 - 75.99) ms | +1.5% | ✅⬆️ |
| runtime.dotnet.exceptions.count | 0 ± (0 - 0) | 0 ± (0 - 0) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 10.62 ± (10.62 - 10.62) MB | 10.63 ± (10.63 - 10.63) MB | +0.1% | ✅⬆️ |
| runtime.dotnet.threads.count | 10 ± (10 - 10) | 10 ± (10 - 10) | +0.0% | ✅ |
| .NET 6 - Bailout | ||||
| process.internal_duration_ms | 21.37 ± (21.32 - 21.43) ms | 21.47 ± (21.41 - 21.54) ms | +0.5% | ✅⬆️ |
| process.time_to_main_ms | 75.87 ± (75.57 - 76.18) ms | 75.65 ± (75.33 - 75.97) ms | -0.3% | ✅ |
| runtime.dotnet.exceptions.count | 0 ± (0 - 0) | 0 ± (0 - 0) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 10.68 ± (10.67 - 10.68) MB | 10.66 ± (10.66 - 10.66) MB | -0.1% | ✅ |
| runtime.dotnet.threads.count | 11 ± (11 - 11) | 11 ± (11 - 11) | +0.0% | ✅ |
| .NET 6 - CallTarget+Inlining+NGEN | ||||
| process.internal_duration_ms | 209.70 ± (208.61 - 210.79) ms | 209.41 ± (208.25 - 210.58) ms | -0.1% | ✅ |
| process.time_to_main_ms | 465.91 ± (464.89 - 466.94) ms | 468.36 ± (467.16 - 469.56) ms | +0.5% | ✅⬆️ |
| runtime.dotnet.exceptions.count | 0 ± (0 - 0) | 0 ± (0 - 0) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 48.29 ± (48.27 - 48.32) MB | 48.37 ± (48.33 - 48.41) MB | +0.2% | ✅⬆️ |
| runtime.dotnet.threads.count | 28 ± (28 - 28) | 28 ± (28 - 28) | -0.1% | ✅ |
| .NET 8 - Baseline | ||||
| process.internal_duration_ms | 19.62 ± (19.55 - 19.68) ms | 19.87 ± (19.80 - 19.93) ms | +1.3% | ✅⬆️ |
| process.time_to_main_ms | 73.67 ± (73.35 - 73.98) ms | 75.12 ± (74.73 - 75.50) ms | +2.0% | ✅⬆️ |
| runtime.dotnet.exceptions.count | 0 ± (0 - 0) | 0 ± (0 - 0) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 7.68 ± (7.67 - 7.68) MB | 7.66 ± (7.65 - 7.66) MB | -0.3% | ✅ |
| runtime.dotnet.threads.count | 10 ± (10 - 10) | 10 ± (10 - 10) | +0.0% | ✅ |
| .NET 8 - Bailout | ||||
| process.internal_duration_ms | 19.67 ± (19.61 - 19.74) ms | 19.80 ± (19.72 - 19.87) ms | +0.6% | ✅⬆️ |
| process.time_to_main_ms | 75.30 ± (74.99 - 75.60) ms | 76.51 ± (76.11 - 76.90) ms | +1.6% | ✅⬆️ |
| runtime.dotnet.exceptions.count | 0 ± (0 - 0) | 0 ± (0 - 0) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 7.72 ± (7.71 - 7.72) MB | 7.71 ± (7.70 - 7.72) MB | -0.1% | ✅ |
| runtime.dotnet.threads.count | 11 ± (11 - 11) | 11 ± (11 - 11) | +0.0% | ✅ |
| .NET 8 - CallTarget+Inlining+NGEN | ||||
| process.internal_duration_ms | 190.77 ± (189.81 - 191.73) ms | 190.04 ± (189.05 - 191.02) ms | -0.4% | ✅ |
| process.time_to_main_ms | 447.20 ± (446.43 - 447.98) ms | 452.75 ± (451.61 - 453.89) ms | +1.2% | ✅⬆️ |
| runtime.dotnet.exceptions.count | 0 ± (0 - 0) | 0 ± (0 - 0) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 36.43 ± (36.39 - 36.46) MB | 36.46 ± (36.41 - 36.50) MB | +0.1% | ✅⬆️ |
| runtime.dotnet.threads.count | 27 ± (27 - 27) | 27 ± (27 - 27) | +0.1% | ✅⬆️ |
HttpMessageHandler
| Metric | Master (Mean ± 95% CI) | Current (Mean ± 95% CI) | Change | Status |
|---|---|---|---|---|
| .NET Framework 4.8 - Baseline | ||||
| duration | 194.72 ± (194.83 - 195.80) ms | 195.52 ± (195.58 - 196.47) ms | +0.4% | ✅⬆️ |
| .NET Framework 4.8 - Bailout | ||||
| duration | 199.07 ± (199.00 - 199.87) ms | 199.09 ± (198.81 - 199.71) ms | +0.0% | ✅⬆️ |
| .NET Framework 4.8 - CallTarget+Inlining+NGEN | ||||
| duration | 1124.26 ± (1128.02 - 1138.07) ms | 1120.91 ± (1124.88 - 1133.15) ms | -0.3% | ✅ |
| .NET Core 3.1 - Baseline | ||||
| process.internal_duration_ms | 189.79 ± (189.36 - 190.23) ms | 189.98 ± (189.54 - 190.42) ms | +0.1% | ✅⬆️ |
| process.time_to_main_ms | 81.40 ± (81.18 - 81.61) ms | 81.48 ± (81.28 - 81.69) ms | +0.1% | ✅⬆️ |
| runtime.dotnet.exceptions.count | 3 ± (3 - 3) | 3 ± (3 - 3) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 16.11 ± (16.09 - 16.14) MB | 16.09 ± (16.07 - 16.12) MB | -0.1% | ✅ |
| runtime.dotnet.threads.count | 20 ± (19 - 20) | 20 ± (20 - 20) | +0.4% | ✅⬆️ |
| .NET Core 3.1 - Bailout | ||||
| process.internal_duration_ms | 190.10 ± (189.66 - 190.54) ms | 189.10 ± (188.65 - 189.55) ms | -0.5% | ✅ |
| process.time_to_main_ms | 82.83 ± (82.65 - 83.01) ms | 82.47 ± (82.28 - 82.66) ms | -0.4% | ✅ |
| runtime.dotnet.exceptions.count | 3 ± (3 - 3) | 3 ± (3 - 3) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 16.14 ± (16.12 - 16.17) MB | 16.12 ± (16.10 - 16.14) MB | -0.1% | ✅ |
| runtime.dotnet.threads.count | 21 ± (20 - 21) | 21 ± (21 - 21) | +0.1% | ✅⬆️ |
| .NET Core 3.1 - CallTarget+Inlining+NGEN | ||||
| process.internal_duration_ms | 400.64 ± (397.80 - 403.49) ms | 396.77 ± (394.38 - 399.17) ms | -1.0% | ✅ |
| process.time_to_main_ms | 477.07 ± (476.31 - 477.83) ms | 479.24 ± (478.52 - 479.97) ms | +0.5% | ✅⬆️ |
| runtime.dotnet.exceptions.count | 3 ± (3 - 3) | 3 ± (3 - 3) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 58.84 ± (58.70 - 58.99) MB | 58.64 ± (58.50 - 58.78) MB | -0.3% | ✅ |
| runtime.dotnet.threads.count | 29 ± (29 - 29) | 30 ± (29 - 30) | +0.2% | ✅⬆️ |
| .NET 6 - Baseline | ||||
| process.internal_duration_ms | 194.72 ± (194.27 - 195.16) ms | 194.23 ± (193.80 - 194.66) ms | -0.2% | ✅ |
| process.time_to_main_ms | 70.47 ± (70.26 - 70.69) ms | 70.15 ± (69.97 - 70.34) ms | -0.5% | ✅ |
| runtime.dotnet.exceptions.count | 4 ± (4 - 4) | 4 ± (4 - 4) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 16.36 ± (16.33 - 16.39) MB | 16.30 ± (16.22 - 16.38) MB | -0.4% | ✅ |
| runtime.dotnet.threads.count | 19 ± (19 - 19) | 19 ± (19 - 19) | -0.7% | ✅ |
| .NET 6 - Bailout | ||||
| process.internal_duration_ms | 193.53 ± (193.02 - 194.03) ms | 192.96 ± (192.60 - 193.32) ms | -0.3% | ✅ |
| process.time_to_main_ms | 71.41 ± (71.24 - 71.57) ms | 71.10 ± (70.97 - 71.23) ms | -0.4% | ✅ |
| runtime.dotnet.exceptions.count | 4 ± (4 - 4) | 4 ± (4 - 4) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 16.25 ± (16.13 - 16.36) MB | 16.20 ± (16.07 - 16.33) MB | -0.3% | ✅ |
| runtime.dotnet.threads.count | 19 ± (19 - 20) | 20 ± (20 - 20) | +2.1% | ✅⬆️ |
| .NET 6 - CallTarget+Inlining+NGEN | ||||
| process.internal_duration_ms | 415.62 ± (413.17 - 418.07) ms | 409.37 ± (407.25 - 411.48) ms | -1.5% | ✅ |
| process.time_to_main_ms | 447.96 ± (447.30 - 448.61) ms | 449.84 ± (449.20 - 450.48) ms | +0.4% | ✅⬆️ |
| runtime.dotnet.exceptions.count | 4 ± (4 - 4) | 4 ± (4 - 4) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 59.32 ± (59.22 - 59.43) MB | 59.04 ± (58.89 - 59.18) MB | -0.5% | ✅ |
| runtime.dotnet.threads.count | 30 ± (29 - 30) | 29 ± (29 - 30) | -0.0% | ✅ |
| .NET 8 - Baseline | ||||
| process.internal_duration_ms | 192.63 ± (192.22 - 193.04) ms | 192.70 ± (192.23 - 193.17) ms | +0.0% | ✅⬆️ |
| process.time_to_main_ms | 70.43 ± (70.19 - 70.66) ms | 69.83 ± (69.65 - 70.01) ms | -0.8% | ✅ |
| runtime.dotnet.exceptions.count | 4 ± (4 - 4) | 4 ± (4 - 4) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 11.67 ± (11.65 - 11.69) MB | 11.71 ± (11.69 - 11.73) MB | +0.4% | ✅⬆️ |
| runtime.dotnet.threads.count | 18 ± (18 - 18) | 18 ± (18 - 18) | +0.1% | ✅⬆️ |
| .NET 8 - Bailout | ||||
| process.internal_duration_ms | 190.95 ± (190.57 - 191.33) ms | 192.72 ± (192.23 - 193.20) ms | +0.9% | ✅⬆️ |
| process.time_to_main_ms | 70.64 ± (70.47 - 70.80) ms | 71.30 ± (71.12 - 71.48) ms | +0.9% | ✅⬆️ |
| runtime.dotnet.exceptions.count | 4 ± (4 - 4) | 4 ± (4 - 4) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 11.72 ± (11.70 - 11.74) MB | 11.79 ± (11.77 - 11.82) MB | +0.6% | ✅⬆️ |
| runtime.dotnet.threads.count | 19 ± (19 - 19) | 19 ± (19 - 19) | +1.1% | ✅⬆️ |
| .NET 8 - CallTarget+Inlining+NGEN | ||||
| process.internal_duration_ms | 369.15 ± (367.76 - 370.54) ms | 368.89 ± (367.52 - 370.27) ms | -0.1% | ✅ |
| process.time_to_main_ms | 433.08 ± (432.29 - 433.88) ms | 433.06 ± (432.42 - 433.70) ms | -0.0% | ✅ |
| runtime.dotnet.exceptions.count | 4 ± (4 - 4) | 4 ± (4 - 4) | +0.0% | ✅ |
| runtime.dotnet.mem.committed | 47.97 ± (47.94 - 48.00) MB | 47.98 ± (47.96 - 48.01) MB | +0.0% | ✅⬆️ |
| runtime.dotnet.threads.count | 29 ± (29 - 29) | 29 ± (29 - 29) | +0.6% | ✅⬆️ |
Comparison explanation
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 highlighted 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).
Duration charts
FakeDbCommand (.NET Framework 4.8)
gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7939) - mean (74ms) : 68, 80
master - mean (75ms) : 70, 80
section Bailout
This PR (7939) - mean (79ms) : 73, 85
master - mean (79ms) : 74, 84
section CallTarget+Inlining+NGEN
This PR (7939) - mean (1,069ms) : 1004, 1133
master - mean (1,064ms) : 1014, 1114
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 (7939) - mean (116ms) : 110, 123
master - mean (116ms) : 110, 122
section Bailout
This PR (7939) - mean (118ms) : 112, 125
master - mean (119ms) : 112, 125
section CallTarget+Inlining+NGEN
This PR (7939) - mean (765ms) : 723, 807
master - mean (760ms) : 722, 799
FakeDbCommand (.NET 6)
gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7939) - mean (104ms) : 97, 112
master - mean (103ms) : 97, 109
section Bailout
This PR (7939) - mean (104ms) : 98, 109
master - mean (104ms) : 98, 110
section CallTarget+Inlining+NGEN
This PR (7939) - mean (706ms) : 667, 745
master - mean (702ms) : 675, 729
FakeDbCommand (.NET 8)
gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7939) - mean (103ms) : 95, 112
master - mean (101ms) : 94, 109
section Bailout
This PR (7939) - mean (105ms) : 97, 112
master - mean (103ms) : 98, 109
section CallTarget+Inlining+NGEN
This PR (7939) - mean (673ms) : 643, 702
master - mean (666ms) : 643, 689
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 (7939) - mean (196ms) : 191, 201
master - mean (195ms) : 189, 201
section Bailout
This PR (7939) - mean (199ms) : 195, 204
master - mean (199ms) : 195, 204
section CallTarget+Inlining+NGEN
This PR (7939) - mean (1,129ms) : 1068, 1190
master - mean (1,133ms) : 1058, 1208
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 (7939) - mean (280ms) : 270, 290
master - mean (279ms) : 272, 286
section Bailout
This PR (7939) - mean (280ms) : 273, 287
master - mean (281ms) : 273, 290
section CallTarget+Inlining+NGEN
This PR (7939) - mean (914ms) : 867, 962
master - mean (916ms) : 868, 965
HttpMessageHandler (.NET 6)
gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7939) - mean (273ms) : 264, 282
master - mean (274ms) : 265, 282
section Bailout
This PR (7939) - mean (272ms) : 267, 278
master - mean (273ms) : 267, 279
section CallTarget+Inlining+NGEN
This PR (7939) - mean (891ms) : 852, 930
master - mean (898ms) : 853, 943
HttpMessageHandler (.NET 8)
gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7939) - mean (272ms) : 265, 279
master - mean (273ms) : 266, 280
section Bailout
This PR (7939) - mean (274ms) : 265, 283
master - mean (271ms) : 266, 276
section CallTarget+Inlining+NGEN
This PR (7939) - mean (833ms) : 813, 852
master - mean (833ms) : 811, 855