From 455051fc76c0303d9e2f0ab951f581b45b9a5576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20N=C3=A4geli?= Date: Wed, 12 Nov 2025 07:51:09 +0100 Subject: [PATCH 1/4] Switch to GenHTTP 10 & .NET 10 --- .../genhttp/Benchmarks/Benchmarks.csproj | 13 +++++---- .../CSharp/genhttp/Benchmarks/Program.cs | 4 +++ .../CSharp/genhttp/benchmark_config.json | 28 +++++++++++++++++-- frameworks/CSharp/genhttp/config.toml | 18 ++++++++++++ .../CSharp/genhttp/genhttp-kestrel.dockerfile | 27 ++++++++++++++++++ frameworks/CSharp/genhttp/genhttp.dockerfile | 11 +++++--- 6 files changed, 90 insertions(+), 11 deletions(-) create mode 100644 frameworks/CSharp/genhttp/genhttp-kestrel.dockerfile diff --git a/frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj b/frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj index 1189d0c151c..f25466ff4eb 100644 --- a/frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj +++ b/frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj @@ -2,14 +2,16 @@ - net9.0 - 13.0 + net10.0 + 14.0 true Exe GenHTTP Benchmarks Test suite to be executed with TechEmpower FrameworkBenchmarks. + $(DefineConstants);$(GENHTTP_ENGINE_NAME) + true true @@ -26,10 +28,11 @@ - - + + + - + diff --git a/frameworks/CSharp/genhttp/Benchmarks/Program.cs b/frameworks/CSharp/genhttp/Benchmarks/Program.cs index dd55ad6b782..91323662c2d 100644 --- a/frameworks/CSharp/genhttp/Benchmarks/Program.cs +++ b/frameworks/CSharp/genhttp/Benchmarks/Program.cs @@ -1,7 +1,11 @@ using Benchmarks.Tests; using Benchmarks.Utilities; +#if INTERNAL using GenHTTP.Engine.Internal; +#else +using GenHTTP.Engine.Kestrel; +#endif using GenHTTP.Modules.IO; using GenHTTP.Modules.Layouting; diff --git a/frameworks/CSharp/genhttp/benchmark_config.json b/frameworks/CSharp/genhttp/benchmark_config.json index bf1780e753a..ea0648c3614 100644 --- a/frameworks/CSharp/genhttp/benchmark_config.json +++ b/frameworks/CSharp/genhttp/benchmark_config.json @@ -17,11 +17,35 @@ "language": "C#", "orm": "Raw", "platform": ".NET", - "webserver": "Kestrel", + "webserver": "GenHTTP", "os": "Linux", "database_os": "Linux", "display_name": "GenHTTP", "notes": "" } - }] + }, + { + "kestrel": { + "plaintext_url": "/plaintext", + "json_url": "/json", + "db_url": "/db", + "query_url": "/queries/", + "update_url": "/updates/", + "fortune_url": "/fortunes", + "cached_query_url": "/cached-worlds/", + "port": 8080, + "approach": "Realistic", + "classification": "Fullstack", + "database": "Postgres", + "framework": "GenHTTP", + "language": "C#", + "orm": "Raw", + "platform": ".NET", + "webserver": "Kestrel", + "os": "Linux", + "database_os": "Linux", + "display_name": "GenHTTP [Kestrel]", + "notes": "" + } + }] } diff --git a/frameworks/CSharp/genhttp/config.toml b/frameworks/CSharp/genhttp/config.toml index f984318f53b..538213c05b4 100644 --- a/frameworks/CSharp/genhttp/config.toml +++ b/frameworks/CSharp/genhttp/config.toml @@ -16,5 +16,23 @@ database_os = "Linux" os = "Linux" orm = "Raw" platform = ".NET" +webserver = "GenHTTP" +versus = "None" + +[kestrel] +urls.plaintext = "/plaintext" +urls.json = "/json" +urls.db = "/db" +urls.query = "/queries/" +urls.update = "/updates/" +urls.fortune = "/fortunes" +urls.cached_query = "/cached-worlds/" +approach = "Realistic" +classification = "Fullstack" +database = "Postgres" +database_os = "Linux" +os = "Linux" +orm = "Raw" +platform = ".NET" webserver = "Kestrel" versus = "None" diff --git a/frameworks/CSharp/genhttp/genhttp-kestrel.dockerfile b/frameworks/CSharp/genhttp/genhttp-kestrel.dockerfile new file mode 100644 index 00000000000..d92b0e9d731 --- /dev/null +++ b/frameworks/CSharp/genhttp/genhttp-kestrel.dockerfile @@ -0,0 +1,27 @@ +FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS build +WORKDIR /source + +ENV GENHTTP_ENGINE_NAME=KESTREL +ENV GENHTTP_ENGINE_PACKAGE=GenHTTP.Core.Kestrel + +# copy csproj and restore as distinct layers +COPY kestrel/*.csproj . +RUN dotnet restore -r linux-musl-x64 + +# copy and publish app and libraries +COPY kestrel/ . +RUN dotnet publish -c release -o /app -r linux-musl-x64 --no-restore --self-contained + +# final stage/image +FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-alpine + +ENV DOTNET_GCDynamicAdaptationMode=0 +ENV DOTNET_ReadyToRun=0 +ENV DOTNET_HillClimbing_Disable=1 + +WORKDIR /app +COPY --from=build /app . + +ENTRYPOINT ["./Benchmarks"] + +EXPOSE 8080 diff --git a/frameworks/CSharp/genhttp/genhttp.dockerfile b/frameworks/CSharp/genhttp/genhttp.dockerfile index 8c473477a61..5e13c8a2617 100644 --- a/frameworks/CSharp/genhttp/genhttp.dockerfile +++ b/frameworks/CSharp/genhttp/genhttp.dockerfile @@ -1,16 +1,19 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build +FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS build WORKDIR /source +ENV GENHTTP_ENGINE_NAME=INTERNAL +ENV GENHTTP_ENGINE_PACKAGE=GenHTTP.Core + # copy csproj and restore as distinct layers -COPY Benchmarks/*.csproj . +COPY internal/*.csproj . RUN dotnet restore -r linux-musl-x64 # copy and publish app and libraries -COPY Benchmarks/ . +COPY internal/ . RUN dotnet publish -c release -o /app -r linux-musl-x64 --no-restore --self-contained # final stage/image -FROM mcr.microsoft.com/dotnet/runtime-deps:9.0-alpine +FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-alpine ENV DOTNET_GCDynamicAdaptationMode=0 ENV DOTNET_ReadyToRun=0 From d6713bd2a0504790d774654b7264995a1cbd1142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20N=C3=A4geli?= Date: Wed, 12 Nov 2025 07:56:09 +0100 Subject: [PATCH 2/4] Fix directories in the docker file --- frameworks/CSharp/genhttp/genhttp-kestrel.dockerfile | 4 ++-- frameworks/CSharp/genhttp/genhttp.dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frameworks/CSharp/genhttp/genhttp-kestrel.dockerfile b/frameworks/CSharp/genhttp/genhttp-kestrel.dockerfile index d92b0e9d731..77f35858f69 100644 --- a/frameworks/CSharp/genhttp/genhttp-kestrel.dockerfile +++ b/frameworks/CSharp/genhttp/genhttp-kestrel.dockerfile @@ -5,11 +5,11 @@ ENV GENHTTP_ENGINE_NAME=KESTREL ENV GENHTTP_ENGINE_PACKAGE=GenHTTP.Core.Kestrel # copy csproj and restore as distinct layers -COPY kestrel/*.csproj . +COPY Benchmarks/*.csproj . RUN dotnet restore -r linux-musl-x64 # copy and publish app and libraries -COPY kestrel/ . +COPY Benchmarks/ . RUN dotnet publish -c release -o /app -r linux-musl-x64 --no-restore --self-contained # final stage/image diff --git a/frameworks/CSharp/genhttp/genhttp.dockerfile b/frameworks/CSharp/genhttp/genhttp.dockerfile index 5e13c8a2617..b9bf5d4fea7 100644 --- a/frameworks/CSharp/genhttp/genhttp.dockerfile +++ b/frameworks/CSharp/genhttp/genhttp.dockerfile @@ -5,11 +5,11 @@ ENV GENHTTP_ENGINE_NAME=INTERNAL ENV GENHTTP_ENGINE_PACKAGE=GenHTTP.Core # copy csproj and restore as distinct layers -COPY internal/*.csproj . +COPY Benchmarks/*.csproj . RUN dotnet restore -r linux-musl-x64 # copy and publish app and libraries -COPY internal/ . +COPY Benchmarks/ . RUN dotnet publish -c release -o /app -r linux-musl-x64 --no-restore --self-contained # final stage/image From 4f3205f8dc80a2c76768c40423f876917149180e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20N=C3=A4geli?= Date: Wed, 12 Nov 2025 09:59:29 +0100 Subject: [PATCH 3/4] Fix DB tests, minor improvements --- .../genhttp/Benchmarks/Benchmarks.csproj | 2 +- .../genhttp/Benchmarks/Tests/JsonHandler.cs | 12 +++---- .../Utilities/FixedLengthJsonContent.cs | 31 +++++++++++++++++++ .../CSharp/genhttp/benchmark_config.json | 5 +-- .../CSharp/genhttp/genhttp-kestrel.dockerfile | 12 +++++-- frameworks/CSharp/genhttp/genhttp.dockerfile | 12 +++++-- 6 files changed, 57 insertions(+), 17 deletions(-) create mode 100644 frameworks/CSharp/genhttp/Benchmarks/Utilities/FixedLengthJsonContent.cs diff --git a/frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj b/frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj index f25466ff4eb..ae302d86dbb 100644 --- a/frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj +++ b/frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj @@ -33,7 +33,7 @@ - + diff --git a/frameworks/CSharp/genhttp/Benchmarks/Tests/JsonHandler.cs b/frameworks/CSharp/genhttp/Benchmarks/Tests/JsonHandler.cs index 4944c669198..7fb89b926d7 100644 --- a/frameworks/CSharp/genhttp/Benchmarks/Tests/JsonHandler.cs +++ b/frameworks/CSharp/genhttp/Benchmarks/Tests/JsonHandler.cs @@ -1,10 +1,8 @@ -using System.Text.Json; +using Benchmarks.Utilities; using GenHTTP.Api.Content; using GenHTTP.Api.Protocol; -using GenHTTP.Modules.Conversion.Serializers.Json; - namespace Benchmarks.Tests; public sealed class JsonResult @@ -15,9 +13,7 @@ public sealed class JsonResult public sealed class JsonHandler : IHandler { - private static readonly FlexibleContentType _ContentType = new(ContentType.ApplicationJson, "utf-8"); - - private static readonly JsonSerializerOptions _Options = new(); + private static readonly FlexibleContentType ContentType = new(GenHTTP.Api.Protocol.ContentType.ApplicationJson, "utf-8"); public ValueTask PrepareAsync() => new(); @@ -29,8 +25,8 @@ public ValueTask HandleAsync(IRequest request) }; var response = request.Respond() - .Content(new JsonContent(result, _Options)) - .Type(_ContentType) + .Content(new FixedLengthJsonContent(result)) + .Type(ContentType) .Build(); return new(response); diff --git a/frameworks/CSharp/genhttp/Benchmarks/Utilities/FixedLengthJsonContent.cs b/frameworks/CSharp/genhttp/Benchmarks/Utilities/FixedLengthJsonContent.cs new file mode 100644 index 00000000000..7ef372c65f0 --- /dev/null +++ b/frameworks/CSharp/genhttp/Benchmarks/Utilities/FixedLengthJsonContent.cs @@ -0,0 +1,31 @@ +using System.Text.Json; + +using GenHTTP.Api.Protocol; + +using Benchmarks.Tests; + +namespace Benchmarks.Utilities; + +public sealed class FixedLengthJsonContent : IResponseContent +{ + private readonly MemoryStream _buffer = new(); + + public ulong? Length => (ulong)_buffer.Length; + + public FixedLengthJsonContent(JsonResult result) + { + JsonSerializer.SerializeAsync(_buffer, result); + } + + public ValueTask CalculateChecksumAsync() => throw new NotImplementedException(); + + public ValueTask WriteAsync(Stream target, uint bufferSize) + { + _buffer.Seek(0, SeekOrigin.Begin); + + _buffer.CopyTo(target); + + return ValueTask.CompletedTask; + } + +} diff --git a/frameworks/CSharp/genhttp/benchmark_config.json b/frameworks/CSharp/genhttp/benchmark_config.json index ea0648c3614..e41ff5e8dd3 100644 --- a/frameworks/CSharp/genhttp/benchmark_config.json +++ b/frameworks/CSharp/genhttp/benchmark_config.json @@ -1,5 +1,6 @@ { - "framework": "genhttp", + "framework": "genhttp", + "maintainers": ["Kaliumhexacyanoferrat"], "tests": [{ "default": { "plaintext_url": "/plaintext", @@ -44,7 +45,7 @@ "webserver": "Kestrel", "os": "Linux", "database_os": "Linux", - "display_name": "GenHTTP [Kestrel]", + "display_name": "ASP.NET Core [GenHTTP]", "notes": "" } }] diff --git a/frameworks/CSharp/genhttp/genhttp-kestrel.dockerfile b/frameworks/CSharp/genhttp/genhttp-kestrel.dockerfile index 77f35858f69..e345a538f34 100644 --- a/frameworks/CSharp/genhttp/genhttp-kestrel.dockerfile +++ b/frameworks/CSharp/genhttp/genhttp-kestrel.dockerfile @@ -15,9 +15,15 @@ RUN dotnet publish -c release -o /app -r linux-musl-x64 --no-restore --self-cont # final stage/image FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-alpine -ENV DOTNET_GCDynamicAdaptationMode=0 -ENV DOTNET_ReadyToRun=0 -ENV DOTNET_HillClimbing_Disable=1 +ENV DOTNET_GCDynamicAdaptationMode=0 \ + DOTNET_EnableDiagnostics=0 \ + COMPlus_EnableDiagnostics=0 \ + COMPlus_DbgEnableMiniDump=0 \ + COMPlus_DbgEnableMiniDumpCollection=0 \ + COMPlus_DbgMiniDumpType=0 \ + DOTNET_TieredPGO=0 \ + DOTNET_TC_QuickJitForLoops=1 \ + DOTNET_TC_QuickJit=1 WORKDIR /app COPY --from=build /app . diff --git a/frameworks/CSharp/genhttp/genhttp.dockerfile b/frameworks/CSharp/genhttp/genhttp.dockerfile index b9bf5d4fea7..9414123202e 100644 --- a/frameworks/CSharp/genhttp/genhttp.dockerfile +++ b/frameworks/CSharp/genhttp/genhttp.dockerfile @@ -15,9 +15,15 @@ RUN dotnet publish -c release -o /app -r linux-musl-x64 --no-restore --self-cont # final stage/image FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-alpine -ENV DOTNET_GCDynamicAdaptationMode=0 -ENV DOTNET_ReadyToRun=0 -ENV DOTNET_HillClimbing_Disable=1 +ENV DOTNET_GCDynamicAdaptationMode=0 \ + DOTNET_EnableDiagnostics=0 \ + COMPlus_EnableDiagnostics=0 \ + COMPlus_DbgEnableMiniDump=0 \ + COMPlus_DbgEnableMiniDumpCollection=0 \ + COMPlus_DbgMiniDumpType=0 \ + DOTNET_TieredPGO=0 \ + DOTNET_TC_QuickJitForLoops=1 \ + DOTNET_TC_QuickJit=1 WORKDIR /app COPY --from=build /app . From 131e8ace85be74a50d0943ee0c29b77dbd1fc1a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20N=C3=A4geli?= Date: Thu, 13 Nov 2025 00:22:40 +0100 Subject: [PATCH 4/4] Align display names with unhinged --- frameworks/CSharp/genhttp/benchmark_config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/CSharp/genhttp/benchmark_config.json b/frameworks/CSharp/genhttp/benchmark_config.json index e41ff5e8dd3..2943457c204 100644 --- a/frameworks/CSharp/genhttp/benchmark_config.json +++ b/frameworks/CSharp/genhttp/benchmark_config.json @@ -21,7 +21,7 @@ "webserver": "GenHTTP", "os": "Linux", "database_os": "Linux", - "display_name": "GenHTTP", + "display_name": "genhttp [internal]", "notes": "" } }, @@ -45,7 +45,7 @@ "webserver": "Kestrel", "os": "Linux", "database_os": "Linux", - "display_name": "ASP.NET Core [GenHTTP]", + "display_name": "genhttp [kestrel]", "notes": "" } }]