Replace remaining usages of Environment.Version#8069
Conversation
| { | ||
| internal static class RuntimeHelper | ||
| { | ||
| internal static bool IsNetOnward(int major) |
There was a problem hiding this comment.
This was only used in the one place, above, so just inlined it for clarity
0fa1bd8 to
3a61929
Compare
| private bool CheckIfMethodMayBeOmittedFromCallStack() | ||
| { | ||
| return ExceptionTrackManager.IsEditAndContinueFeatureEnabled && | ||
| FrameworkDescription.Instance.IsCoreClr() && RuntimeHelper.IsNetOnward(6) && Method.Method.DeclaringType?.Assembly != null && RuntimeHelper.IsModuleDebugCompiled(Method.Method.DeclaringType.Assembly); |
There was a problem hiding this comment.
RuntimeHelper.IsNetOnward(6) implies FrameworkDescription.Instance.IsCoreClr() so the first check is redundant
|
|
||
| // ASP.NET Core metrics are only available on .NET 8+ | ||
| _aspnetcoreMetricsAvailable = Environment.Version.Major >= 8; | ||
| var version = FrameworkDescription.Instance.RuntimeVersion; |
There was a problem hiding this comment.
Just extract the variable and use the existing version
| public bool IsCoreClr() | ||
| { | ||
| return Name.ToLowerInvariant().Contains("core") || IsNet5(); | ||
| return RuntimeVersion.Major >= 5 || Name.IndexOf("core", StringComparison.OrdinalIgnoreCase) >= 0; |
There was a problem hiding this comment.
Don't allocate when looking for "core"
BenchmarksBenchmark execution time: 2026-01-15 19:52:47 Comparing candidate commit f71aeeb in PR branch Found 11 performance improvements and 1 performance regressions! Performance is the same for 166 metrics, 14 unstable metrics. scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net6.0
scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody netcoreapp3.1
scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody netcoreapp3.1
scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net6.0
scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1
scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net6.0
scenario:Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery net472
scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog netcoreapp3.1
scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore netcoreapp3.1
|
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (8069) 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 (8069) - mean (69ms) : 66, 71
master - mean (68ms) : 67, 70
section Bailout
This PR (8069) - mean (72ms) : 72, 73
master - mean (72ms) : 70, 74
section CallTarget+Inlining+NGEN
This PR (8069) - mean (1,018ms) : 941, 1095
master - mean (1,010ms) : 949, 1070
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 (8069) - mean (106ms) : 104, 109
master - mean (106ms) : 104, 109
section Bailout
This PR (8069) - mean (107ms) : 106, 108
master - mean (107ms) : 106, 108
section CallTarget+Inlining+NGEN
This PR (8069) - mean (753ms) : 703, 803
master - mean (738ms) : 672, 803
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8069) - mean (94ms) : 92, 96
master - mean (94ms) : 91, 96
section Bailout
This PR (8069) - mean (95ms) : 94, 96
master - mean (95ms) : 94, 95
section CallTarget+Inlining+NGEN
This PR (8069) - mean (732ms) : 694, 771
master - mean (721ms) : 695, 747
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8069) - mean (93ms) : 90, 96
master - mean (92ms) : 90, 95
section Bailout
This PR (8069) - mean (94ms) : 93, 95
master - mean (94ms) : 92, 95
section CallTarget+Inlining+NGEN
This PR (8069) - mean (641ms) : 623, 659
master - mean (635ms) : 621, 650
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 (8069) - mean (195ms) : 191, 199
master - mean (194ms) : 190, 199
section Bailout
This PR (8069) - mean (198ms) : 195, 201
master - mean (198ms) : 195, 202
section CallTarget+Inlining+NGEN
This PR (8069) - mean (1,130ms) : 1071, 1189
master - mean (1,135ms) : 1072, 1197
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 (8069) - mean (277ms) : 271, 284
master - mean (280ms) : 273, 286
section Bailout
This PR (8069) - mean (278ms) : 274, 283
master - mean (282ms) : 272, 291
section CallTarget+Inlining+NGEN
This PR (8069) - mean (933ms) : 885, 981
master - mean (941ms) : 895, 987
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8069) - mean (272ms) : 266, 278
master - mean (273ms) : 266, 280
section Bailout
This PR (8069) - mean (271ms) : 268, 274
master - mean (272ms) : 268, 276
section CallTarget+Inlining+NGEN
This PR (8069) - mean (927ms) : 879, 976
master - mean (935ms) : 889, 981
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8069) - mean (270ms) : 265, 276
master - mean (271ms) : 264, 278
section Bailout
This PR (8069) - mean (270ms) : 267, 274
master - mean (270ms) : 267, 273
section CallTarget+Inlining+NGEN
This PR (8069) - mean (833ms) : 814, 852
master - mean (839ms) : 819, 859
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3a61929 to
f71aeeb
Compare
| _ when Environment.Version is { Major: 3, Minor: 0 } => false, // 3.0 is broken on linux | ||
| { RuntimeVersion: { Major: >= 5 } } => true, // Works on .NET 5 and above | ||
| { RuntimeVersion: { Major: 3, Minor: > 0 } } => true, // 3.1 works | ||
| { RuntimeVersion: { Major: 3, Minor: 0 } } => false, // 3.0 is broken on linux |
There was a problem hiding this comment.
Why not remove this line and let it fall into the default branch?
Summary of changes
Replaced remaining usages of
Environment.Versionother thanFrameworkDescriptionReason for change
Environment.Versionallocates, but it's used in a bunch of places unnecessarily. Switching to useFrameworkDescription.Runtimeversionremoves those allocationsImplementation details
Environment.Versionand fix it to notIsCoreClr()Test coverage
Should be covered by existing
Other details
Stacked on
Environment.Versioncausing huge allocation #8068