From 61b3c56d94a4f6f014bb58686f2f19f9268f99cb Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Fri, 2 Dec 2022 00:00:58 +0100 Subject: [PATCH] Update SDK to .NET 7, re-enable NativeAOT tests, fix some other tests (#2209) * update SDK to 7.0 * update samples and test projects to .NET 7 * bump NativeAOT tests to .NET 7, re-enable some of them * handle edge case to get the tests passing again * don't run Full Framework tests on AppVeyor to avoid build timeouts * avoid reflection when possible * NativeAOT is not supported on macOS with .NET 7 * run fewer tests on AppVeyor to avoid getting timeouts --- build/Build.csproj | 2 +- build/Program.cs | 17 +++++------ build/global.json | 2 +- .../RedirectGenerator.csproj | 2 +- .../BenchmarkDotNet.Samples.FSharp.fsproj | 2 +- .../BenchmarkDotNet.Samples.csproj | 2 +- src/BenchmarkDotNet/Engines/GcStats.cs | 7 ++++- src/BenchmarkDotNet/Toolchains/Executor.cs | 13 ++++++++- ....IntegrationTests.ConfigPerAssembly.csproj | 2 +- ...egrationTests.DisabledOptimizations.csproj | 2 +- ...tegrationTests.EnabledOptimizations.csproj | 2 +- ...hmarkDotNet.IntegrationTests.FSharp.fsproj | 2 +- ...tNet.IntegrationTests.ManualRunning.csproj | 2 +- ...hmarkDotNet.IntegrationTests.Static.csproj | 2 +- ...DotNet.IntegrationTests.VisualBasic.vbproj | 2 +- .../BenchmarkDotNet.IntegrationTests.csproj | 2 +- .../BuildTimeoutTests.cs | 10 +++---- .../DisassemblyDiagnoserTests.cs | 2 +- .../JitRuntimeValidationTest.cs | 2 +- .../LargeAddressAwareTest.cs | 6 ++-- .../MemoryDiagnoserTests.cs | 28 ++++++------------- .../MonoTests.cs | 4 +-- .../MultipleRuntimesTest.cs | 4 +-- .../NativeAotTests.cs | 8 +++--- .../ThreadingDiagnoserTests.cs | 9 ++---- .../BenchmarkDotNet.Tests.csproj | 2 +- 26 files changed, 70 insertions(+), 68 deletions(-) diff --git a/build/Build.csproj b/build/Build.csproj index 4cb47e4f84..2e8cb69919 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -1,7 +1,7 @@ Exe - net6.0 + net7.0 $(MSBuildProjectDirectory) diff --git a/build/Program.cs b/build/Program.cs index 82258e5d52..df59b52802 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -63,7 +63,8 @@ public class BuildContext : FrostingContext public DotNetCoreMSBuildSettings MsBuildSettings { get; } private IAppVeyorProvider AppVeyor => this.BuildSystem().AppVeyor; - public bool IsOnAppVeyorAndNotPr => AppVeyor.IsRunningOnAppVeyor && !AppVeyor.Environment.PullRequest.IsPullRequest; + public bool IsRunningOnAppVeyor => AppVeyor.IsRunningOnAppVeyor; + public bool IsOnAppVeyorAndNotPr => IsRunningOnAppVeyor && !AppVeyor.Environment.PullRequest.IsPullRequest; public bool IsOnAppVeyorAndBdnNightlyCiCd => IsOnAppVeyorAndNotPr && AppVeyor.Environment.Repository.Branch == "master" && this.IsRunningOnWindows(); public bool IsLocalBuild => this.BuildSystem().IsLocalBuild; public bool IsCiBuild => !this.BuildSystem().IsLocalBuild; @@ -338,8 +339,8 @@ public override bool ShouldRun(BuildContext context) public override void Run(BuildContext context) { var targetFrameworks = context.IsRunningOnWindows() - ? new[] { "net462", "net6.0" } - : new[] { "net6.0" }; + ? new[] { "net462", "net7.0" } + : new[] { "net7.0" }; foreach (var targetFramework in targetFrameworks) context.RunTests(context.UnitTestsProjectFile, "UnitTests", targetFramework); @@ -352,7 +353,7 @@ public class SlowFullFrameworkTestsTask : FrostingTask { public override bool ShouldRun(BuildContext context) { - return !context.SkipTests && !context.SkipSlowTests && context.IsRunningOnWindows(); + return !context.SkipTests && !context.SkipSlowTests && context.IsRunningOnWindows() && !context.IsRunningOnAppVeyor; } public override void Run(BuildContext context) @@ -361,9 +362,9 @@ public override void Run(BuildContext context) } } -[TaskName("SlowTestsNet5")] +[TaskName("SlowTestsNetCore")] [IsDependentOn(typeof(BuildTask))] -public class SlowTestsNet5Task : FrostingTask +public class SlowTestsNetCoreTask : FrostingTask { public override bool ShouldRun(BuildContext context) { @@ -372,14 +373,14 @@ public override bool ShouldRun(BuildContext context) public override void Run(BuildContext context) { - context.RunTests(context.IntegrationTestsProjectFile, "IntegrationTests", "net6.0"); + context.RunTests(context.IntegrationTestsProjectFile, "IntegrationTests", "net7.0"); } } [TaskName("AllTests")] [IsDependentOn(typeof(FastTestsTask))] [IsDependentOn(typeof(SlowFullFrameworkTestsTask))] -[IsDependentOn(typeof(SlowTestsNet5Task))] +[IsDependentOn(typeof(SlowTestsNetCoreTask))] public class AllTestsTask : FrostingTask { } diff --git a/build/global.json b/build/global.json index a44fa0e1dc..a1a3ee1ea3 100644 --- a/build/global.json +++ b/build/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.201", + "version": "7.0.100", "rollForward": "disable" } } \ No newline at end of file diff --git a/docs/_redirects/RedirectGenerator/RedirectGenerator.csproj b/docs/_redirects/RedirectGenerator/RedirectGenerator.csproj index 40c60dd4c8..d439800007 100644 --- a/docs/_redirects/RedirectGenerator/RedirectGenerator.csproj +++ b/docs/_redirects/RedirectGenerator/RedirectGenerator.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net7.0 enable enable diff --git a/samples/BenchmarkDotNet.Samples.FSharp/BenchmarkDotNet.Samples.FSharp.fsproj b/samples/BenchmarkDotNet.Samples.FSharp/BenchmarkDotNet.Samples.FSharp.fsproj index d507038e01..55045658d8 100644 --- a/samples/BenchmarkDotNet.Samples.FSharp/BenchmarkDotNet.Samples.FSharp.fsproj +++ b/samples/BenchmarkDotNet.Samples.FSharp/BenchmarkDotNet.Samples.FSharp.fsproj @@ -5,7 +5,7 @@ Exe - net462;net6.0 + net462;net7.0 diff --git a/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj b/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj index 8d0d311d5b..a05f17a7b4 100644 --- a/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj +++ b/samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj @@ -2,7 +2,7 @@ BenchmarkDotNet.Samples - net462;net6.0 + net462;net7.0 true BenchmarkDotNet.Samples Exe diff --git a/src/BenchmarkDotNet/Engines/GcStats.cs b/src/BenchmarkDotNet/Engines/GcStats.cs index ae39c4718e..afcf73f515 100644 --- a/src/BenchmarkDotNet/Engines/GcStats.cs +++ b/src/BenchmarkDotNet/Engines/GcStats.cs @@ -13,9 +13,10 @@ public struct GcStats : IEquatable public static readonly long AllocationQuantum = CalculateAllocationQuantumSize(); +#if !NET6_0_OR_GREATER private static readonly Func GetAllocatedBytesForCurrentThreadDelegate = CreateGetAllocatedBytesForCurrentThreadDelegate(); private static readonly Func GetTotalAllocatedBytesDelegate = CreateGetTotalAllocatedBytesDelegate(); - +#endif public static readonly GcStats Empty = new GcStats(0, 0, 0, 0, 0); private GcStats(int gen0Collections, int gen1Collections, int gen2Collections, long allocatedBytes, long totalOperations) @@ -142,11 +143,15 @@ private static long GetAllocatedBytes() if (RuntimeInformation.IsFullFramework) // it can be a .NET app consuming our .NET Standard package return AppDomain.CurrentDomain.MonitoringTotalAllocatedMemorySize; +#if NET6_0_OR_GREATER + return GC.GetTotalAllocatedBytes(precise: true); +#else if (GetTotalAllocatedBytesDelegate != null) // it's .NET Core 3.0 with the new API available return GetTotalAllocatedBytesDelegate.Invoke(true); // true for the "precise" argument // https://apisof.net/catalog/System.GC.GetAllocatedBytesForCurrentThread() is not part of the .NET Standard, so we use reflection to call it.. return GetAllocatedBytesForCurrentThreadDelegate.Invoke(); +#endif } private static Func CreateGetAllocatedBytesForCurrentThreadDelegate() diff --git a/src/BenchmarkDotNet/Toolchains/Executor.cs b/src/BenchmarkDotNet/Toolchains/Executor.cs index 8eb0576a76..85afb75a3b 100644 --- a/src/BenchmarkDotNet/Toolchains/Executor.cs +++ b/src/BenchmarkDotNet/Toolchains/Executor.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel; using System.Diagnostics; using System.IO; using System.IO.Pipes; @@ -67,7 +68,17 @@ private static ExecuteResult Execute(Process process, BenchmarkCase benchmarkCas { logger.WriteLineInfo($"// Execute: {process.StartInfo.FileName} {process.StartInfo.Arguments} in {process.StartInfo.WorkingDirectory}"); - process.Start(); + try + { + process.Start(); + } + catch (Win32Exception ex) + { + logger.WriteLineError($"// Failed to start the benchmark process: {ex}"); + + return new ExecuteResult(true, null, null, Array.Empty(), Array.Empty(), Array.Empty(), launchIndex); + } + processOutputReader.BeginRead(); process.EnsureHighPriority(logger); diff --git a/tests/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj b/tests/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj index a9abc217ce..e559ace0a9 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj @@ -2,7 +2,7 @@ BenchmarkDotNet.IntegrationTests.ConfigPerAssembly - net462;net6.0 + net462;net7.0 true BenchmarkDotNet.IntegrationTests.ConfigPerAssembly BenchmarkDotNet.IntegrationTests.ConfigPerAssembly diff --git a/tests/BenchmarkDotNet.IntegrationTests.DisabledOptimizations/BenchmarkDotNet.IntegrationTests.DisabledOptimizations.csproj b/tests/BenchmarkDotNet.IntegrationTests.DisabledOptimizations/BenchmarkDotNet.IntegrationTests.DisabledOptimizations.csproj index c0cf5e72f9..15723e07e5 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.DisabledOptimizations/BenchmarkDotNet.IntegrationTests.DisabledOptimizations.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.DisabledOptimizations/BenchmarkDotNet.IntegrationTests.DisabledOptimizations.csproj @@ -2,7 +2,7 @@ BenchmarkDotNet.IntegrationTests.DisabledOptimizations - net462;net6.0 + net462;net7.0 true BenchmarkDotNet.IntegrationTests.DisabledOptimizations BenchmarkDotNet.IntegrationTests.DisabledOptimizations diff --git a/tests/BenchmarkDotNet.IntegrationTests.EnabledOptimizations/BenchmarkDotNet.IntegrationTests.EnabledOptimizations.csproj b/tests/BenchmarkDotNet.IntegrationTests.EnabledOptimizations/BenchmarkDotNet.IntegrationTests.EnabledOptimizations.csproj index d67555d114..593dbbae16 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.EnabledOptimizations/BenchmarkDotNet.IntegrationTests.EnabledOptimizations.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.EnabledOptimizations/BenchmarkDotNet.IntegrationTests.EnabledOptimizations.csproj @@ -2,7 +2,7 @@ BenchmarkDotNet.IntegrationTests.EnabledOptimizations - net462;net6.0 + net462;net7.0 true BenchmarkDotNet.IntegrationTests.EnabledOptimizations BenchmarkDotNet.IntegrationTests.EnabledOptimizations diff --git a/tests/BenchmarkDotNet.IntegrationTests.FSharp/BenchmarkDotNet.IntegrationTests.FSharp.fsproj b/tests/BenchmarkDotNet.IntegrationTests.FSharp/BenchmarkDotNet.IntegrationTests.FSharp.fsproj index 1b24615b29..6feefadc37 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.FSharp/BenchmarkDotNet.IntegrationTests.FSharp.fsproj +++ b/tests/BenchmarkDotNet.IntegrationTests.FSharp/BenchmarkDotNet.IntegrationTests.FSharp.fsproj @@ -5,7 +5,7 @@ - net462;net6.0 + net462;net7.0 false diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj index 57a7d5051e..2271948201 100755 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj @@ -2,7 +2,7 @@ BenchmarkDotNet.IntegrationTests.ManualRunning - net462;net6.0 + net462;net7.0 true BenchmarkDotNet.IntegrationTests.ManualRunning BenchmarkDotNet.IntegrationTests.ManualRunning diff --git a/tests/BenchmarkDotNet.IntegrationTests.Static/BenchmarkDotNet.IntegrationTests.Static.csproj b/tests/BenchmarkDotNet.IntegrationTests.Static/BenchmarkDotNet.IntegrationTests.Static.csproj index 41219e6893..8ff856ecb5 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.Static/BenchmarkDotNet.IntegrationTests.Static.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.Static/BenchmarkDotNet.IntegrationTests.Static.csproj @@ -2,7 +2,7 @@ BenchmarkDotNet.IntegrationTests.Static - net462;net6.0 + net462;net7.0 true BenchmarkDotNet.IntegrationTests.Static BenchmarkDotNet.IntegrationTests.Static diff --git a/tests/BenchmarkDotNet.IntegrationTests.VisualBasic/BenchmarkDotNet.IntegrationTests.VisualBasic.vbproj b/tests/BenchmarkDotNet.IntegrationTests.VisualBasic/BenchmarkDotNet.IntegrationTests.VisualBasic.vbproj index 5e5def4f86..973fbb08c2 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.VisualBasic/BenchmarkDotNet.IntegrationTests.VisualBasic.vbproj +++ b/tests/BenchmarkDotNet.IntegrationTests.VisualBasic/BenchmarkDotNet.IntegrationTests.VisualBasic.vbproj @@ -5,7 +5,7 @@ - net462;net6.0 + net462;net7.0 diff --git a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj index 48e1f1a6e8..0eadb6053c 100755 --- a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj @@ -2,7 +2,7 @@ BenchmarkDotNet.IntegrationTests - net462;net6.0 + net462;net7.0 true BenchmarkDotNet.IntegrationTests BenchmarkDotNet.IntegrationTests diff --git a/tests/BenchmarkDotNet.IntegrationTests/BuildTimeoutTests.cs b/tests/BenchmarkDotNet.IntegrationTests/BuildTimeoutTests.cs index 5efd67a67e..5893df2740 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/BuildTimeoutTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/BuildTimeoutTests.cs @@ -19,6 +19,8 @@ public void WhenBuildTakesMoreTimeThanTheTimeoutTheBuildIsCancelled() { if (!RuntimeInformation.Is64BitPlatform()) // NativeAOT does not support 32bit yet return; + if (RuntimeInformation.IsMacOSX()) + return; // currently not supported // we use NativeAOT on purpose because it takes a LOT of time to build it // so we can be sure that timeout = 1s should fail! @@ -27,12 +29,10 @@ public void WhenBuildTakesMoreTimeThanTheTimeoutTheBuildIsCancelled() var config = ManualConfig.CreateEmpty() .WithBuildTimeout(timeout) .AddJob(Job.Dry - .WithRuntime(NativeAotRuntime.Net60) + .WithRuntime(NativeAotRuntime.Net70) .WithToolchain(NativeAotToolchain.CreateBuilder() - .UseNuGet( - "6.0.0-rc.1.21420.1", // we test against specific version to keep this test stable - "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json") // using old feed that supports net6.0 - .TargetFrameworkMoniker("net6.0") + .UseNuGet("7.0.0", "https://api.nuget.org/v3/index.json") + .TargetFrameworkMoniker("net7.0") .ToToolchain())); var summary = CanExecute(config, fullValidation: false); diff --git a/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs index 765eac111c..dbb9ae3c8b 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs @@ -33,7 +33,7 @@ public static IEnumerable GetAllJits() new object[] { Jit.RyuJit, Platform.X64, ClrRuntime.Net462 }, // RyuJit for desktop .NET #endif - new object[] { Jit.RyuJit, Platform.X64, CoreRuntime.Core60 }, // .NET Core + new object[] { Jit.RyuJit, Platform.X64, CoreRuntime.Core70 }, // .NET Core // we could add new object[] { Jit.Llvm, Platform.X64, new MonoRuntime() } here but our CI would need to have Mono installed.. }; diff --git a/tests/BenchmarkDotNet.IntegrationTests/JitRuntimeValidationTest.cs b/tests/BenchmarkDotNet.IntegrationTests/JitRuntimeValidationTest.cs index 92b6b85106..42e7ac2f2b 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/JitRuntimeValidationTest.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/JitRuntimeValidationTest.cs @@ -45,7 +45,7 @@ public void CheckClrOnWindows(Jit jit, Platform platform, string errorMessage) [InlineData(Jit.RyuJit, Platform.X64, null)] public void CheckCore(Jit jit, Platform platform, string errorMessage) { - Verify(CoreRuntime.Core60, jit, platform, errorMessage); + Verify(CoreRuntime.Core70, jit, platform, errorMessage); } private void Verify(Runtime runtime, Jit jit, Platform platform, string errorMessage) diff --git a/tests/BenchmarkDotNet.IntegrationTests/LargeAddressAwareTest.cs b/tests/BenchmarkDotNet.IntegrationTests/LargeAddressAwareTest.cs index 0fd81bf793..522e67a463 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/LargeAddressAwareTest.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/LargeAddressAwareTest.cs @@ -25,8 +25,8 @@ public void BenchmarkCanAllocateMoreThan2Gb() var summary = BenchmarkRunner .Run( ManualConfig.CreateEmpty() - .AddJob(Job.Dry.WithRuntime(CoreRuntime.Core60).WithPlatform(Platform.X64).WithId("Core")) - .AddJob(Job.Dry.WithRuntime(ClrRuntime.Net462).WithPlatform(Platform.X86).WithLargeAddressAware().WithId("Framework")) + .AddJob(Job.Dry.WithRuntime(CoreRuntime.Core70).WithPlatform(Platform.X64).WithId("Core")) + .AddJob(Job.Dry.WithRuntime(ClrRuntime.Net462).WithPlatform(Platform.X86).WithGcServer(false).WithLargeAddressAware().WithId("Framework")) .AddColumnProvider(DefaultColumnProviders.Instance) .AddLogger(new OutputLogger(output))); @@ -47,7 +47,7 @@ public void BenchmarkCanAllocateMoreThan2Gb() .Any()); Assert.Contains(".NET Framework", summary.AllRuntimes); - Assert.Contains(".NET 6.0", summary.AllRuntimes); + Assert.Contains(".NET 7.0", summary.AllRuntimes); } } diff --git a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs index 170476d30a..6b7574eb24 100755 --- a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs @@ -60,24 +60,21 @@ public void MemoryDiagnoserIsAccurate(IToolchain toolchain) { { nameof(AccurateAllocations.EightBytesArray), 8 + objectAllocationOverhead + arraySizeOverhead }, { nameof(AccurateAllocations.SixtyFourBytesArray), 64 + objectAllocationOverhead + arraySizeOverhead }, - { nameof(AccurateAllocations.AllocateTask), CalculateRequiredSpace>() }, }); } - [FactDotNetCoreOnly("We don't want to test NativeAOT twice (for .NET Framework 4.6.2 and .NET 6.0)")] + [FactDotNetCoreOnly("We don't want to test NativeAOT twice (for .NET Framework 4.6.2 and .NET 7.0)")] public void MemoryDiagnoserSupportsNativeAOT() { - if (ContinuousIntegration.IsAppVeyorOnWindows()) // too time consuming for AppVeyor (1h limit) - return; - if (RuntimeInformation.GetCurrentPlatform() == Platform.Arm64 && RuntimeInformation.IsMacOSX()) - return; // Native compilation does not support targeting osx-arm64 yet. https://github.com/dotnet/corert/issues/4589 + if (RuntimeInformation.IsMacOSX()) + return; // currently not supported + if (ContinuousIntegration.IsAppVeyorOnWindows()) + return; // timeouts MemoryDiagnoserIsAccurate( NativeAotToolchain.CreateBuilder() - .UseNuGet( - "6.0.0-rc.1.21420.1", // we test against specific version to keep this test stable - "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json") + .UseNuGet("7.0.0", "https://api.nuget.org/v3/index.json") .ToToolchain()); } @@ -221,9 +218,6 @@ public byte[] SixtyFourBytesArray() [Trait(Constants.Category, Constants.BackwardCompatibilityCategory)] public void AllocationQuantumIsNotAnIssueForNetCore21Plus(IToolchain toolchain) { - if (toolchain is NativeAotToolchain) // the fix has not yet been backported to NativeAOT - return; - long objectAllocationOverhead = IntPtr.Size * 2; // pointer to method table + object header word long arraySizeOverhead = IntPtr.Size; // array length @@ -263,9 +257,6 @@ public void Allocate() [Trait(Constants.Category, Constants.BackwardCompatibilityCategory)] public void MemoryDiagnoserIsAccurateForMultiThreadedBenchmarks(IToolchain toolchain) { - if (toolchain is NativeAotToolchain) // the API has not been yet ported to NativeAOT - return; - long objectAllocationOverhead = IntPtr.Size * 2; // pointer to method table + object header word long arraySizeOverhead = IntPtr.Size; // array length long memoryAllocatedPerArray = (MultiThreadedAllocation.Size + objectAllocationOverhead + arraySizeOverhead); @@ -287,11 +278,6 @@ private void AssertAllocations(IToolchain toolchain, Type benchmarkType, Diction foreach (var benchmarkAllocationsValidator in benchmarksAllocationsValidators) { - // NativeAOT is missing some of the CoreCLR threading/task related perf improvements, so sizeof(Task) calculated for CoreCLR < sizeof(Task) on CoreRT - // see https://github.com/dotnet/corert/issues/5705 for more - if (benchmarkAllocationsValidator.Key == nameof(AccurateAllocations.AllocateTask) && toolchain is NativeAotToolchain) - continue; - var allocatingBenchmarks = benchmarks.BenchmarksCases.Where(benchmark => benchmark.DisplayInfo.Contains(benchmarkAllocationsValidator.Key)); foreach (var benchmark in allocatingBenchmarks) @@ -315,6 +301,8 @@ private IConfig CreateConfig(IToolchain toolchain) .WithWarmupCount(0) // don't run warmup to save some time for our CI runs .WithIterationCount(1) // single iteration is enough for us .WithGcForce(false) + .WithGcServer(false) + .WithGcConcurrent(false) .WithEnvironmentVariable("COMPlus_TieredCompilation", "0") // Tiered JIT can allocate some memory on a background thread, let's disable it to make our tests less flaky (#1542) .WithToolchain(toolchain)) .AddColumnProvider(DefaultColumnProviders.Instance) diff --git a/tests/BenchmarkDotNet.IntegrationTests/MonoTests.cs b/tests/BenchmarkDotNet.IntegrationTests/MonoTests.cs index 2dacf85173..cd4a08d809 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/MonoTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/MonoTests.cs @@ -10,9 +10,9 @@ namespace BenchmarkDotNet.IntegrationTests public class MonoTests : BenchmarkTestExecutor { [FactDotNetCoreOnly("UseMonoRuntime option is available in .NET Core only starting from .NET 6")] - public void Mono60IsSupported() + public void Mono70IsSupported() { - var config = ManualConfig.CreateEmpty().AddJob(Job.Dry.WithRuntime(MonoRuntime.Mono60)); + var config = ManualConfig.CreateEmpty().AddJob(Job.Dry.WithRuntime(MonoRuntime.Mono70)); CanExecute(config); } diff --git a/tests/BenchmarkDotNet.IntegrationTests/MultipleRuntimesTest.cs b/tests/BenchmarkDotNet.IntegrationTests/MultipleRuntimesTest.cs index b2d05d96e8..eab97609e1 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/MultipleRuntimesTest.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/MultipleRuntimesTest.cs @@ -29,7 +29,7 @@ public void SingleBenchmarkCanBeExecutedForMultipleRuntimes() var summary = BenchmarkRunner .Run( ManualConfig.CreateEmpty() - .AddJob(Job.Dry.WithRuntime(CoreRuntime.Core60).WithPlatform(Platform.X64).WithId("Core")) + .AddJob(Job.Dry.WithRuntime(CoreRuntime.Core70).WithPlatform(Platform.X64).WithId("Core")) .AddJob(Job.Dry.WithRuntime(ClrRuntime.Net462).WithId("Framework")) .AddColumnProvider(DefaultColumnProviders.Instance) .AddLogger(new OutputLogger(output))); @@ -51,7 +51,7 @@ public void SingleBenchmarkCanBeExecutedForMultipleRuntimes() .Any()); Assert.Contains(".NET Framework", summary.AllRuntimes); - Assert.Contains(".NET 6.0", summary.AllRuntimes); + Assert.Contains(".NET 7.0", summary.AllRuntimes); } } diff --git a/tests/BenchmarkDotNet.IntegrationTests/NativeAotTests.cs b/tests/BenchmarkDotNet.IntegrationTests/NativeAotTests.cs index ee1fc2e0bb..15fe8a7a6a 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/NativeAotTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/NativeAotTests.cs @@ -21,10 +21,10 @@ public void LatestNativeAotVersionIsSupported() return; if (ContinuousIntegration.IsGitHubActionsOnWindows()) // no native dependencies installed return; - if (ContinuousIntegration.IsAppVeyorOnWindows()) // too time consuming for AppVeyor (1h limit) - return; - if (NativeAotRuntime.GetCurrentVersion().RuntimeMoniker < RuntimeMoniker.NativeAot70) // we can't target net6.0 and use .NET 7 ILCompiler anymore (#2080) - return; + if (ContinuousIntegration.IsAppVeyorOnWindows()) + return; // timeouts + if (RuntimeInformation.IsMacOSX()) + return; // currently not supported var toolchain = NativeAotToolchain.CreateBuilder().UseNuGet().IlcInstructionSet(IsAvx2Supported() ? "avx2" : "").ToToolchain(); diff --git a/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs index b30f962233..c8ed414c49 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs @@ -31,15 +31,12 @@ public static IEnumerable GetToolchains() { yield return new object[] { Job.Default.GetToolchain() }; - bool isOsxArm64 = RuntimeInformation.GetCurrentPlatform() == Platform.Arm64 && RuntimeInformation.IsMacOSX(); if (!ContinuousIntegration.IsGitHubActionsOnWindows() // no native dependencies - && !ContinuousIntegration.IsAppVeyorOnWindows() // too time consuming for AppVeyor (1h limit) - && !isOsxArm64) // Native compilation does not support targeting osx-arm64 yet. https://github.com/dotnet/corert/issues/4589 + && !RuntimeInformation.IsMacOSX()) // currently not supported { yield return new object[]{ NativeAotToolchain.CreateBuilder() - .UseNuGet( - "6.0.0-rc.1.21420.1", - "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json").ToToolchain() }; + .UseNuGet("7.0.0", "https://api.nuget.org/v3/index.json") + .ToToolchain() }; } // TODO: Support InProcessEmitToolchain.Instance // yield return new object[] { InProcessEmitToolchain.Instance }; diff --git a/tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj b/tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj index 031a325884..dcf8e35a19 100755 --- a/tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj +++ b/tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj @@ -2,7 +2,7 @@ BenchmarkDotNet.Tests - net6.0;net462 + net7.0;net462 BenchmarkDotNet.Tests BenchmarkDotNet.Tests true