diff --git a/frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj b/frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj index 1189d0c151c..ae302d86dbb 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,11 +28,12 @@ - - + + + - - + + 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/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 bf1780e753a..2943457c204 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", @@ -17,11 +18,35 @@ "language": "C#", "orm": "Raw", "platform": ".NET", - "webserver": "Kestrel", + "webserver": "GenHTTP", "os": "Linux", "database_os": "Linux", - "display_name": "GenHTTP", + "display_name": "genhttp [internal]", "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..e345a538f34 --- /dev/null +++ b/frameworks/CSharp/genhttp/genhttp-kestrel.dockerfile @@ -0,0 +1,33 @@ +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 Benchmarks/*.csproj . +RUN dotnet restore -r linux-musl-x64 + +# copy and publish app and libraries +COPY Benchmarks/ . +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 \ + 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 . + +ENTRYPOINT ["./Benchmarks"] + +EXPOSE 8080 diff --git a/frameworks/CSharp/genhttp/genhttp.dockerfile b/frameworks/CSharp/genhttp/genhttp.dockerfile index 8c473477a61..9414123202e 100644 --- a/frameworks/CSharp/genhttp/genhttp.dockerfile +++ b/frameworks/CSharp/genhttp/genhttp.dockerfile @@ -1,6 +1,9 @@ -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 . RUN dotnet restore -r linux-musl-x64 @@ -10,11 +13,17 @@ COPY Benchmarks/ . 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 -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 .