Skip to content

Commit 2bb509e

Browse files
Update GenHTTP to version 10 and udpate to .NET 10 (#10274)
* Switch to GenHTTP 10 & .NET 10 * Fix directories in the docker file * Fix DB tests, minor improvements * Align display names with unhinged
1 parent 8d81c9b commit 2bb509e

File tree

8 files changed

+142
-23
lines changed

8 files changed

+142
-23
lines changed

frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
<PropertyGroup>
44

5-
<TargetFramework>net9.0</TargetFramework>
6-
<LangVersion>13.0</LangVersion>
5+
<TargetFramework>net10.0</TargetFramework>
6+
<LangVersion>14.0</LangVersion>
77
<ImplicitUsings>true</ImplicitUsings>
88
<OutputType>Exe</OutputType>
99

1010
<AssemblyTitle>GenHTTP Benchmarks</AssemblyTitle>
1111
<Description>Test suite to be executed with TechEmpower FrameworkBenchmarks.</Description>
1212

13+
<DefineConstants>$(DefineConstants);$(GENHTTP_ENGINE_NAME)</DefineConstants>
14+
1315
<ServerGarbageCollection>true</ServerGarbageCollection>
1416
<TieredPGO>true</TieredPGO>
1517

@@ -26,11 +28,12 @@
2628

2729
<ItemGroup>
2830

29-
<PackageReference Include="GenHTTP.Core" Version="9.8.0" />
30-
<PackageReference Include="GenHTTP.Modules.Webservices" Version="9.8.0" />
31+
<PackageReference Include="$(GENHTTP_ENGINE_PACKAGE)" Version="10.0.0" />
32+
33+
<PackageReference Include="GenHTTP.Modules.Webservices" Version="10.0.0" />
3134

32-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.10" />
33-
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
35+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.0" />
36+
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0-rc.2" />
3437

3538
</ItemGroup>
3639

frameworks/CSharp/genhttp/Benchmarks/Program.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
using Benchmarks.Tests;
22
using Benchmarks.Utilities;
33

4+
#if INTERNAL
45
using GenHTTP.Engine.Internal;
6+
#else
7+
using GenHTTP.Engine.Kestrel;
8+
#endif
59

610
using GenHTTP.Modules.IO;
711
using GenHTTP.Modules.Layouting;

frameworks/CSharp/genhttp/Benchmarks/Tests/JsonHandler.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
using System.Text.Json;
1+
using Benchmarks.Utilities;
22

33
using GenHTTP.Api.Content;
44
using GenHTTP.Api.Protocol;
55

6-
using GenHTTP.Modules.Conversion.Serializers.Json;
7-
86
namespace Benchmarks.Tests;
97

108
public sealed class JsonResult
@@ -15,9 +13,7 @@ public sealed class JsonResult
1513

1614
public sealed class JsonHandler : IHandler
1715
{
18-
private static readonly FlexibleContentType _ContentType = new(ContentType.ApplicationJson, "utf-8");
19-
20-
private static readonly JsonSerializerOptions _Options = new();
16+
private static readonly FlexibleContentType ContentType = new(GenHTTP.Api.Protocol.ContentType.ApplicationJson, "utf-8");
2117

2218
public ValueTask PrepareAsync() => new();
2319

@@ -29,8 +25,8 @@ public ValueTask<IResponse> HandleAsync(IRequest request)
2925
};
3026

3127
var response = request.Respond()
32-
.Content(new JsonContent(result, _Options))
33-
.Type(_ContentType)
28+
.Content(new FixedLengthJsonContent(result))
29+
.Type(ContentType)
3430
.Build();
3531

3632
return new(response);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Text.Json;
2+
3+
using GenHTTP.Api.Protocol;
4+
5+
using Benchmarks.Tests;
6+
7+
namespace Benchmarks.Utilities;
8+
9+
public sealed class FixedLengthJsonContent : IResponseContent
10+
{
11+
private readonly MemoryStream _buffer = new();
12+
13+
public ulong? Length => (ulong)_buffer.Length;
14+
15+
public FixedLengthJsonContent(JsonResult result)
16+
{
17+
JsonSerializer.SerializeAsync(_buffer, result);
18+
}
19+
20+
public ValueTask<ulong?> CalculateChecksumAsync() => throw new NotImplementedException();
21+
22+
public ValueTask WriteAsync(Stream target, uint bufferSize)
23+
{
24+
_buffer.Seek(0, SeekOrigin.Begin);
25+
26+
_buffer.CopyTo(target);
27+
28+
return ValueTask.CompletedTask;
29+
}
30+
31+
}

frameworks/CSharp/genhttp/benchmark_config.json

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"framework": "genhttp",
2+
"framework": "genhttp",
3+
"maintainers": ["Kaliumhexacyanoferrat"],
34
"tests": [{
45
"default": {
56
"plaintext_url": "/plaintext",
@@ -17,11 +18,35 @@
1718
"language": "C#",
1819
"orm": "Raw",
1920
"platform": ".NET",
20-
"webserver": "Kestrel",
21+
"webserver": "GenHTTP",
2122
"os": "Linux",
2223
"database_os": "Linux",
23-
"display_name": "GenHTTP",
24+
"display_name": "genhttp [internal]",
2425
"notes": ""
2526
}
26-
}]
27+
},
28+
{
29+
"kestrel": {
30+
"plaintext_url": "/plaintext",
31+
"json_url": "/json",
32+
"db_url": "/db",
33+
"query_url": "/queries/",
34+
"update_url": "/updates/",
35+
"fortune_url": "/fortunes",
36+
"cached_query_url": "/cached-worlds/",
37+
"port": 8080,
38+
"approach": "Realistic",
39+
"classification": "Fullstack",
40+
"database": "Postgres",
41+
"framework": "GenHTTP",
42+
"language": "C#",
43+
"orm": "Raw",
44+
"platform": ".NET",
45+
"webserver": "Kestrel",
46+
"os": "Linux",
47+
"database_os": "Linux",
48+
"display_name": "genhttp [kestrel]",
49+
"notes": ""
50+
}
51+
}]
2752
}

frameworks/CSharp/genhttp/config.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,23 @@ database_os = "Linux"
1616
os = "Linux"
1717
orm = "Raw"
1818
platform = ".NET"
19+
webserver = "GenHTTP"
20+
versus = "None"
21+
22+
[kestrel]
23+
urls.plaintext = "/plaintext"
24+
urls.json = "/json"
25+
urls.db = "/db"
26+
urls.query = "/queries/"
27+
urls.update = "/updates/"
28+
urls.fortune = "/fortunes"
29+
urls.cached_query = "/cached-worlds/"
30+
approach = "Realistic"
31+
classification = "Fullstack"
32+
database = "Postgres"
33+
database_os = "Linux"
34+
os = "Linux"
35+
orm = "Raw"
36+
platform = ".NET"
1937
webserver = "Kestrel"
2038
versus = "None"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS build
2+
WORKDIR /source
3+
4+
ENV GENHTTP_ENGINE_NAME=KESTREL
5+
ENV GENHTTP_ENGINE_PACKAGE=GenHTTP.Core.Kestrel
6+
7+
# copy csproj and restore as distinct layers
8+
COPY Benchmarks/*.csproj .
9+
RUN dotnet restore -r linux-musl-x64
10+
11+
# copy and publish app and libraries
12+
COPY Benchmarks/ .
13+
RUN dotnet publish -c release -o /app -r linux-musl-x64 --no-restore --self-contained
14+
15+
# final stage/image
16+
FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-alpine
17+
18+
ENV DOTNET_GCDynamicAdaptationMode=0 \
19+
DOTNET_EnableDiagnostics=0 \
20+
COMPlus_EnableDiagnostics=0 \
21+
COMPlus_DbgEnableMiniDump=0 \
22+
COMPlus_DbgEnableMiniDumpCollection=0 \
23+
COMPlus_DbgMiniDumpType=0 \
24+
DOTNET_TieredPGO=0 \
25+
DOTNET_TC_QuickJitForLoops=1 \
26+
DOTNET_TC_QuickJit=1
27+
28+
WORKDIR /app
29+
COPY --from=build /app .
30+
31+
ENTRYPOINT ["./Benchmarks"]
32+
33+
EXPOSE 8080

frameworks/CSharp/genhttp/genhttp.dockerfile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build
1+
FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS build
22
WORKDIR /source
33

4+
ENV GENHTTP_ENGINE_NAME=INTERNAL
5+
ENV GENHTTP_ENGINE_PACKAGE=GenHTTP.Core
6+
47
# copy csproj and restore as distinct layers
58
COPY Benchmarks/*.csproj .
69
RUN dotnet restore -r linux-musl-x64
@@ -10,11 +13,17 @@ COPY Benchmarks/ .
1013
RUN dotnet publish -c release -o /app -r linux-musl-x64 --no-restore --self-contained
1114

1215
# final stage/image
13-
FROM mcr.microsoft.com/dotnet/runtime-deps:9.0-alpine
16+
FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-alpine
1417

15-
ENV DOTNET_GCDynamicAdaptationMode=0
16-
ENV DOTNET_ReadyToRun=0
17-
ENV DOTNET_HillClimbing_Disable=1
18+
ENV DOTNET_GCDynamicAdaptationMode=0 \
19+
DOTNET_EnableDiagnostics=0 \
20+
COMPlus_EnableDiagnostics=0 \
21+
COMPlus_DbgEnableMiniDump=0 \
22+
COMPlus_DbgEnableMiniDumpCollection=0 \
23+
COMPlus_DbgMiniDumpType=0 \
24+
DOTNET_TieredPGO=0 \
25+
DOTNET_TC_QuickJitForLoops=1 \
26+
DOTNET_TC_QuickJit=1
1827

1928
WORKDIR /app
2029
COPY --from=build /app .

0 commit comments

Comments
 (0)