Skip to content

Commit

Permalink
feat: add .NET 8 preview and test for performance/regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
skwasjer committed Oct 17, 2023
1 parent ed35b75 commit 6d9b64c
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 45 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ jobs:
7.0.x
6.0.x
3.1.x
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
dotnet-quality: 'preview'

- name: dotnet info
run: dotnet --info
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
7.0.x
6.0.x
3.1.x
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
dotnet-quality: 'preview'

- name: dotnet info
run: dotnet --info
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ jobs:
7.0.x
6.0.x
3.1.x
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
dotnet-quality: 'preview'

- uses: actions/setup-node@v3
with:
Expand Down
5 changes: 3 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@

<PropertyGroup>
<!-- Microsoft.Extensions.* -->
<PackageVersion_Microsoft_Extensions>7.0.0</PackageVersion_Microsoft_Extensions>
<PackageVersion_Microsoft_Extensions>8.0.0-rc.2.23479.6</PackageVersion_Microsoft_Extensions>
<PackageVersion_Microsoft_Extensions Condition="'$(TargetFramework)'=='net7.0'">7.0.0</PackageVersion_Microsoft_Extensions>
<PackageVersion_Microsoft_Extensions Condition="'$(TargetFramework)'=='net6.0'">6.0.0</PackageVersion_Microsoft_Extensions>
<PackageVersion_Microsoft_Extensions Condition="'$(TargetFramework)'!='net6.0' And '$(TargetFramework)'!='net7.0'">3.1.26</PackageVersion_Microsoft_Extensions>
<PackageVersion_Microsoft_Extensions Condition="$(TargetFramework.StartsWith('netstandard2')) Or '$(TargetFramework)'=='netcoreapp3.1'">3.1.26</PackageVersion_Microsoft_Extensions>
</PropertyGroup>

</Project>
7 changes: 7 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ install:
- gitversion /l console /output buildserver
- choco install opencover.portable -y
- choco install codecov -y
# Install 8.0 preview
- ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetsdk"
- ps: mkdir $env:DOTNET_INSTALL_DIR -Force | Out-Null
- ps: Invoke-WebRequest 'https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.ps1' -OutFile "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1"
- ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Channel 8.0.1xx -Quality preview -InstallDir $env:DOTNET_INSTALL_DIR'
- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
- dotnet --list-sdks
cache:
- C:\ProgramData\chocolatey\bin -> appveyor.yml, codecov.yml
- C:\ProgramData\chocolatey\lib -> appveyor.yml, codecov.yml
Expand Down
2 changes: 1 addition & 1 deletion src/Correlate.Abstractions/Correlate.Abstractions.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.0</TargetFrameworks>
<RootNamespace>Correlate</RootNamespace>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Correlate.AspNetCore/Correlate.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netcoreapp3.1</TargetFrameworks>
<RootNamespace>Correlate</RootNamespace>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Correlate.Core/Correlate.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.0</TargetFrameworks>
<RootNamespace>Correlate</RootNamespace>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public async Task Given_that_response_already_contains_correlation_header_when_f
_options.RequestHeaders.Should().NotBeNullOrEmpty();

const string existingCorrelationId = "existing-id";
_responseFeature.Headers.Add(_options.RequestHeaders[0], existingCorrelationId);
_responseFeature.Headers.Append(_options.RequestHeaders[0], existingCorrelationId);

var expectedHeader = new KeyValuePair<string, StringValues>(
_options.RequestHeaders[0],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netcoreapp3.1</TargetFrameworks>
<IsTestProject>true</IsTestProject>
<RootNamespace>Correlate</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0-rc.2.23480.2" Condition="'$(TargetFramework)'=='net8.0'" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.10" Condition="'$(TargetFramework)'=='net7.0'" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.21" Condition="'$(TargetFramework)'=='net6.0'" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.32" Condition="'$(TargetFramework)'=='netcoreapp3.1'" />
Expand Down
10 changes: 5 additions & 5 deletions test/Correlate.Benchmarks/Correlate.Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsTestProject>false</IsTestProject>
<Baseline>true</Baseline>
<CurrentVersion>true</CurrentVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.9" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Correlate.AspNetCore\Correlate.AspNetCore.csproj" Condition="'$(Baseline)'=='true'" />
<ProjectReference Include="..\..\src\Correlate.DependencyInjection\Correlate.DependencyInjection.csproj" Condition="'$(Baseline)'=='true'" />
<ProjectReference Include="..\..\src\Correlate.AspNetCore\Correlate.AspNetCore.csproj" Condition="'$(CurrentVersion)'=='true'" />
<ProjectReference Include="..\..\src\Correlate.DependencyInjection\Correlate.DependencyInjection.csproj" Condition="'$(CurrentVersion)'=='true'" />
</ItemGroup>

</Project>
56 changes: 39 additions & 17 deletions test/Correlate.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@
using BenchmarkDotNet.Toolchains.CsProj;
using Correlate.Benchmarks;

IToolchain[] toolchains = { CsProjCoreToolchain.NetCoreApp70, CsProjCoreToolchain.NetCoreApp60 };

IConfig cfg = DefaultConfig.Instance
.ForAllToolchains(toolchains, Job.Default.WithId("Current"), toolchain => toolchain.Equals(CsProjCoreToolchain.NetCoreApp70))
.ForAllToolchains(toolchains,
Job.Default
.WithId("4.0.0")
.WithToolchain(CsProjCoreToolchain.NetCoreApp70)
.WithNuGet("Correlate.AspNetCore", "4.0.0")
.WithNuGet("Correlate.DependencyInjection", "4.0.0")
.WithArguments(new[] { new MsBuildArgument("/p:Baseline=false") })
);
// To change to .NET 8 once RTM.
IToolchain mostCurrentToolChain = CsProjCoreToolchain.NetCoreApp70;

Version[] versions = {
new("0.0.0"), // Current
new("4.0.0"),
new("5.1.0")
};
IToolchain[] toolchains = { CsProjCoreToolchain.NetCoreApp80, CsProjCoreToolchain.NetCoreApp70, CsProjCoreToolchain.NetCoreApp60 };
IEnumerable<(Version version, IToolchain toolchain)> runs =
from version in versions
from toolchain in toolchains
select (version, toolchain);

IConfig cfg = runs
.Aggregate(DefaultConfig.Instance, (current, run) => current.ForAllToolchains(run.version, run.toolchain, toolchain => toolchain.Equals(mostCurrentToolChain)));

#if RELEASE
BenchmarkRunner.Run<AspNetCoreBenchmark>(cfg);
Expand All @@ -26,14 +30,32 @@

internal static class ConfigExtensions
{
public static IConfig ForAllToolchains(this IConfig config, IEnumerable<IToolchain> toolchains, Job job, Func<IToolchain, bool>? isBaseline = null)
public static IConfig ForAllToolchains(this IConfig config, Version version, IToolchain toolchain, Func<IToolchain, bool> isBaselineToolchain)
{
foreach (IToolchain toolchain in toolchains)
bool isCurrentVersion = version.Major == 0;
string label = isCurrentVersion
? "vNext"
: $"v{version.ToString(3)}";

Job job = Job.Default
.WithToolchain(toolchain)
.WithId(label);

if (!isCurrentVersion)
{
job = job
.WithNuGet("Correlate.AspNetCore", version.ToString(3))
.WithNuGet("Correlate.DependencyInjection", version.ToString(3))
.WithArguments(new[] { new MsBuildArgument("/p:CurrentVersion=false") });
}
else
{
Job j = job.WithToolchain(toolchain);
config = config.AddJob(isBaseline?.Invoke(toolchain) ?? false ? j.AsBaseline() : j);
if (isBaselineToolchain(toolchain))
{
job = job.AsBaseline();
}
}

return config;
return config.AddJob(job);
}
}
30 changes: 18 additions & 12 deletions test/Correlate.Benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
# Benchmark results

```
BenchmarkDotNet v0.13.7, Windows 10 (10.0.19045.3324/22H2/2022Update)
BenchmarkDotNet v0.13.9+228a464e8be6c580ad9408e98f18813f6407fb5a, Windows 10 (10.0.19045.3570/22H2/2022Update)
Intel Core i7-8700K CPU 3.70GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
.NET SDK 7.0.400
[Host] : .NET 7.0.10 (7.0.1023.36312), X64 RyuJIT AVX2
4.0.0 : .NET 6.0.21 (6.0.2123.36311), X64 RyuJIT AVX2
Current : .NET 6.0.21 (6.0.2123.36311), X64 RyuJIT AVX2
.NET SDK 8.0.100-rc.2.23502.2
[Host] : .NET 8.0.0 (8.0.23.47906), X64 RyuJIT AVX2
v4.0.0 : .NET 6.0.23 (6.0.2323.48002), X64 RyuJIT AVX2
v5.1.0 : .NET 6.0.23 (6.0.2323.48002), X64 RyuJIT AVX2
vNext : .NET 6.0.23 (6.0.2323.48002), X64 RyuJIT AVX2
```

| Method | Job | Arguments | NuGetReferences | Toolchain | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio |
|-------- |-------- |------------------ |--------------------------------------------------------------- |---------- |---------:|--------:|--------:|------:|--------:|-------:|----------:|------------:|
| ApiCall | 4.0.0 | /p:Baseline=false | Correlate.AspNetCore 4.0.0,Correlate.DependencyInjection 4.0.0 | .NET 6.0 | 148.2 us | 1.95 us | 1.73 us | 1.02 | 0.02 | 0.4883 | 4.33 KB | 1.11 |
| ApiCall | 4.0.0 | /p:Baseline=false | Correlate.AspNetCore 4.0.0,Correlate.DependencyInjection 4.0.0 | .NET 7.0 | 148.1 us | 0.93 us | 0.87 us | 1.02 | 0.01 | 0.4883 | 4.06 KB | 1.04 |
| ApiCall | Current | Default | Default | .NET 6.0 | 140.2 us | 1.12 us | 1.05 us | 0.96 | 0.01 | 0.4883 | 4.16 KB | 1.07 |
| ApiCall | Current | Default | Default | .NET 7.0 | 145.8 us | 1.07 us | 1.00 us | 1.00 | 0.00 | 0.4883 | 3.91 KB | 1.00 |
| Method | Job | Arguments | NuGetReferences | Toolchain | Mean | Error | StdDev | Median | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio |
|-------- |------- |------------------------ |--------------------------------------------------------------- |---------- |----------:|---------:|---------:|----------:|------:|--------:|-------:|----------:|------------:|
| ApiCall | v4.0.0 | /p:CurrentVersion=false | Correlate.AspNetCore 4.0.0,Correlate.DependencyInjection 4.0.0 | .NET 6.0 | 100.84 us | 2.002 us | 3.997 us | 99.29 us | 1.07 | 0.04 | 0.4883 | 4.33 KB | 1.11 |
| ApiCall | v4.0.0 | /p:CurrentVersion=false | Correlate.AspNetCore 4.0.0,Correlate.DependencyInjection 4.0.0 | .NET 7.0 | 100.84 us | 0.668 us | 0.625 us | 100.74 us | 1.02 | 0.01 | 0.4883 | 4.06 KB | 1.04 |
| ApiCall | v4.0.0 | /p:CurrentVersion=false | Correlate.AspNetCore 4.0.0,Correlate.DependencyInjection 4.0.0 | .NET 8.0 | 88.61 us | 0.517 us | 0.483 us | 88.82 us | 0.90 | 0.01 | 0.4883 | 3.87 KB | 0.99 |
| ApiCall | v5.1.0 | /p:CurrentVersion=false | Correlate.AspNetCore 5.1.0,Correlate.DependencyInjection 5.1.0 | .NET 6.0 | 94.88 us | 0.793 us | 0.742 us | 94.91 us | 0.96 | 0.01 | 0.4883 | 4.17 KB | 1.07 |
| ApiCall | v5.1.0 | /p:CurrentVersion=false | Correlate.AspNetCore 5.1.0,Correlate.DependencyInjection 5.1.0 | .NET 7.0 | 98.08 us | 0.588 us | 0.550 us | 98.15 us | 1.00 | 0.01 | 0.4883 | 3.91 KB | 1.00 |
| ApiCall | v5.1.0 | /p:CurrentVersion=false | Correlate.AspNetCore 5.1.0,Correlate.DependencyInjection 5.1.0 | .NET 8.0 | 84.91 us | 0.578 us | 0.540 us | 84.89 us | 0.86 | 0.01 | 0.4883 | 3.75 KB | 0.96 |
| ApiCall | vNext | Default | Default | .NET 6.0 | 94.09 us | 0.306 us | 0.286 us | 94.09 us | 0.96 | 0.01 | 0.4883 | 4.17 KB | 1.07 |
| ApiCall | vNext | Default | Default | .NET 7.0 | 98.39 us | 0.532 us | 0.498 us | 98.29 us | 1.00 | 0.00 | 0.4883 | 3.91 KB | 1.00 |
| ApiCall | vNext | Default | Default | .NET 8.0 | 85.84 us | 0.854 us | 0.799 us | 85.88 us | 0.87 | 0.01 | 0.4883 | 3.75 KB | 0.96 |

### CLI

To run the benchmark:
```
cd ./test/Correlate.Benchmarks
dotnet run -c Release -f net7.0 net6.0
dotnet run -c Release -f net8.0 net7.0 net6.0
```
2 changes: 1 addition & 1 deletion test/Correlate.Core.Tests/Correlate.Core.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netcoreapp3.1</TargetFrameworks>
<IsTestProject>true</IsTestProject>
<RootNamespace>Correlate</RootNamespace>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netcoreapp3.1</TargetFrameworks>
<IsTestProject>true</IsTestProject>
<RootNamespace>Correlate.DependencyInjection</RootNamespace>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/Correlate.Testing/Correlate.Testing.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.1</TargetFrameworks>
<IsTestProject>false</IsTestProject>
</PropertyGroup>

Expand Down

0 comments on commit 6d9b64c

Please sign in to comment.