From ed54185d44689febc1087b2f3e4b5b41075fb7d6 Mon Sep 17 00:00:00 2001 From: benaadams Date: Mon, 14 Nov 2022 12:57:43 +0000 Subject: [PATCH 1/7] Update to .NET 7 --- .../aspnetcore/Benchmarks/Benchmarks.csproj | 9 ++- .../PlatformBenchmarks/AsciiString.cs | 57 -------------- .../BenchmarkApplication.Fortunes.cs | 10 +-- .../BenchmarkApplication.Json.cs | 10 +-- .../BenchmarkApplication.Plaintext.cs | 10 +-- .../BenchmarkApplication.cs | 78 +++++++++---------- .../PlatformBenchmarks/Data/CachedWorld.cs | 2 +- .../PlatformBenchmarks/DateHeader.cs | 4 +- .../PlatformBenchmarks.csproj | 3 +- .../aspnetcore/PlatformBenchmarks/Program.cs | 15 ++-- .../aspnetcore/aspcore-ado-my.dockerfile | 4 +- .../aspnetcore/aspcore-ado-pg-up.dockerfile | 4 +- .../aspnetcore/aspcore-ado-pg.dockerfile | 4 +- .../aspnetcore/aspcore-mvc-ado-my.dockerfile | 4 +- .../aspcore-mvc-ado-pg-up.dockerfile | 4 +- .../aspnetcore/aspcore-mvc-ado-pg.dockerfile | 4 +- .../aspnetcore/aspcore-mvc-dap-my.dockerfile | 4 +- .../aspcore-mvc-dap-pg-up.dockerfile | 4 +- .../aspnetcore/aspcore-mvc-dap-pg.dockerfile | 4 +- .../aspnetcore/aspcore-mvc-ef-pg.dockerfile | 4 +- .../CSharp/aspnetcore/aspcore-mvc.dockerfile | 4 +- .../aspnetcore/aspcore-mw-ado-my.dockerfile | 4 +- .../aspcore-mw-ado-pg-up.dockerfile | 4 +- .../aspnetcore/aspcore-mw-ado-pg.dockerfile | 4 +- .../aspnetcore/aspcore-mw-dap-my.dockerfile | 4 +- .../aspcore-mw-dap-pg-up.dockerfile | 4 +- .../aspnetcore/aspcore-mw-dap-pg.dockerfile | 4 +- .../aspnetcore/aspcore-mw-ef-pg.dockerfile | 4 +- .../aspnetcore/aspcore-mw-json.dockerfile | 4 +- .../CSharp/aspnetcore/aspcore-mw.dockerfile | 4 +- .../CSharp/aspnetcore/aspcore.dockerfile | 4 +- 31 files changed, 113 insertions(+), 169 deletions(-) delete mode 100644 frameworks/CSharp/aspnetcore/PlatformBenchmarks/AsciiString.cs diff --git a/frameworks/CSharp/aspnetcore/Benchmarks/Benchmarks.csproj b/frameworks/CSharp/aspnetcore/Benchmarks/Benchmarks.csproj index 53993d1f71b..c138ffc0604 100644 --- a/frameworks/CSharp/aspnetcore/Benchmarks/Benchmarks.csproj +++ b/frameworks/CSharp/aspnetcore/Benchmarks/Benchmarks.csproj @@ -1,8 +1,9 @@  - net6.0 + net7.0 Exe enable + true @@ -13,10 +14,10 @@ - + - - + + diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/AsciiString.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/AsciiString.cs deleted file mode 100644 index 34c4a0f0adb..00000000000 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/AsciiString.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Text; - -namespace PlatformBenchmarks; - -public readonly struct AsciiString : IEquatable -{ - private readonly byte[] _data; - - public AsciiString(string s) => _data = Encoding.ASCII.GetBytes(s); - - private AsciiString(byte[] b) => _data = b; - - public int Length => _data.Length; - - public ReadOnlySpan AsSpan() => _data; - - public static implicit operator ReadOnlySpan(AsciiString str) => str._data; - public static implicit operator byte[](AsciiString str) => str._data; - - public static implicit operator AsciiString(string str) => new(str); - - public override string ToString() => Encoding.ASCII.GetString(_data); - public static explicit operator string(AsciiString str) => str.ToString(); - - public bool Equals(AsciiString other) => ReferenceEquals(_data, other._data) || SequenceEqual(_data, other._data); - private bool SequenceEqual(byte[] data1, byte[] data2) => new Span(data1).SequenceEqual(data2); - - public static bool operator ==(AsciiString a, AsciiString b) => a.Equals(b); - public static bool operator !=(AsciiString a, AsciiString b) => !a.Equals(b); - public override bool Equals(object other) => (other is AsciiString @string) && Equals(@string); - - public static AsciiString operator +(AsciiString a, AsciiString b) - { - var result = new byte[a.Length + b.Length]; - a._data.CopyTo(result, 0); - b._data.CopyTo(result, a.Length); - return new AsciiString(result); - } - - public override int GetHashCode() - { - // Copied from x64 version of string.GetLegacyNonRandomizedHashCode() - // https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/String.Comparison.cs - var data = _data; - int hash1 = 5381; - int hash2 = hash1; - foreach (int b in data) - { - hash1 = ((hash1 << 5) + hash1) ^ b; - } - return hash1 + (hash2 * 1566083941); - } - -} diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Fortunes.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Fortunes.cs index a60f6a3fc4a..ee9e94ff12f 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Fortunes.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Fortunes.cs @@ -12,11 +12,11 @@ namespace PlatformBenchmarks { public partial class BenchmarkApplication { - private readonly static AsciiString _fortunesPreamble = - _http11OK + - _headerServer + _crlf + - _headerContentTypeHtml + _crlf + - _headerContentLength; + private static ReadOnlySpan _fortunesPreamble => + "HTTP/1.1 200 OK\r\n"u8 + + "Server: K"u8 + "\r\n"u8 + + "Content-Type: text/html; charset=UTF-8"u8 + "\r\n"u8 + + "Content-Length: "u8; private async Task Fortunes(PipeWriter pipeWriter) { diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Json.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Json.cs index 02835c67f35..42df639c24a 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Json.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Json.cs @@ -10,11 +10,11 @@ public partial class BenchmarkApplication { private readonly static uint _jsonPayloadSize = (uint)JsonSerializer.SerializeToUtf8Bytes(new JsonMessage { message = "Hello, World!" }, SerializerContext.JsonMessage).Length; - private readonly static AsciiString _jsonPreamble = - _http11OK + - _headerServer + _crlf + - _headerContentTypeJson + _crlf + - _headerContentLength + _jsonPayloadSize.ToString(); + private static ReadOnlySpan _jsonPreamble => + "HTTP/1.1 200 OK\r\n"u8 + + "Server: K"u8 + "\r\n"u8 + + "Content-Type: application/json"u8 + "\r\n"u8 + + "Content-Length: 27"u8; private static void Json(ref BufferWriter writer, IBufferWriter bodyWriter) { diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Plaintext.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Plaintext.cs index 809ef6b3741..16a7c0f76eb 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Plaintext.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Plaintext.cs @@ -5,11 +5,11 @@ namespace PlatformBenchmarks; public partial class BenchmarkApplication { - private readonly static AsciiString _plaintextPreamble = - _http11OK + - _headerServer + _crlf + - _headerContentTypeText + _crlf + - _headerContentLength + _plainTextBody.Length.ToString(); + private static ReadOnlySpan _plaintextPreamble => + "HTTP/1.1 200 OK\r\n"u8 + + "Server: K\r\n"u8 + + "Content-Type: text/plain\r\n"u8 + + "Content-Length: 13"u8; private static void PlainText(ref BufferWriter writer) { diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs index b6a78f227d9..2ff1b8157e0 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs @@ -14,27 +14,27 @@ namespace PlatformBenchmarks; public partial class BenchmarkApplication { - private readonly static AsciiString _applicationName = "Kestrel Platform-Level Application"; - public static AsciiString ApplicationName => _applicationName; - - private readonly static AsciiString _crlf = "\r\n"; - private readonly static AsciiString _eoh = "\r\n\r\n"; // End Of Headers - private readonly static AsciiString _http11OK = "HTTP/1.1 200 OK\r\n"; - private readonly static AsciiString _http11NotFound = "HTTP/1.1 404 Not Found\r\n"; - private readonly static AsciiString _headerServer = "Server: K"; - private readonly static AsciiString _headerContentLength = "Content-Length: "; - private readonly static AsciiString _headerContentLengthZero = "Content-Length: 0"; - private readonly static AsciiString _headerContentTypeText = "Content-Type: text/plain"; - private readonly static AsciiString _headerContentTypeJson = "Content-Type: application/json"; - private readonly static AsciiString _headerContentTypeHtml = "Content-Type: text/html; charset=UTF-8"; - - private readonly static AsciiString _dbPreamble = - _http11OK + - _headerServer + _crlf + - _headerContentTypeJson + _crlf + - _headerContentLength; - - private readonly static AsciiString _plainTextBody = "Hello, World!"; + private static ReadOnlySpan _applicationName => "Kestrel Platform-Level Application"u8; + public static ReadOnlySpan ApplicationName => _applicationName; + + private static ReadOnlySpan _crlf => "\r\n"u8; + private static ReadOnlySpan _eoh => "\r\n\r\n"u8; // End Of Headers + private static ReadOnlySpan _http11OK => "HTTP/1.1 200 OK\r\n"u8; + private static ReadOnlySpan _http11NotFound => "HTTP/1.1 404 Not Found\r\n"u8; + private static ReadOnlySpan _headerServer => "Server: K"u8; + private static ReadOnlySpan _headerContentLength => "Content-Length: "u8; + private static ReadOnlySpan _headerContentLengthZero => "Content-Length: 0"u8; + private static ReadOnlySpan _headerContentTypeText => "Content-Type: text/plain"u8; + private static ReadOnlySpan _headerContentTypeJson => "Content-Type: application/json"u8; + private static ReadOnlySpan _headerContentTypeHtml => "Content-Type: text/html; charset=UTF-8"u8; + + private static ReadOnlySpan _dbPreamble => + "HTTP/1.1 200 OK\r\n"u8 + + "Server: K\r\n"u8 + + "Content-Type: application/json\r\n"u8 + + "Content-Length: "u8; + + private static ReadOnlySpan _plainTextBody => "Hello, World!"u8; private static readonly JsonContext SerializerContext = JsonContext.Default; @@ -46,12 +46,12 @@ private sealed partial class JsonContext : JsonSerializerContext { } - private readonly static AsciiString _fortunesTableStart = "Fortunes"; - private readonly static AsciiString _fortunesRowStart = ""; - private readonly static AsciiString _fortunesTableEnd = "
idmessage
"; - private readonly static AsciiString _fortunesColumn = ""; - private readonly static AsciiString _fortunesRowEnd = "
"; - private readonly static AsciiString _contentLengthGap = new string(' ', 4); + private static ReadOnlySpan _fortunesTableStart => "Fortunes"u8; + private static ReadOnlySpan _fortunesRowStart => ""u8; + private static ReadOnlySpan _fortunesTableEnd => "
idmessage
"u8; + private static ReadOnlySpan _fortunesColumn => ""u8; + private static ReadOnlySpan _fortunesRowEnd => "
"u8; + private static ReadOnlySpan _contentLengthGap => " "u8; #if DATABASE public static RawDb Db { get; set; } @@ -62,13 +62,13 @@ private sealed partial class JsonContext : JsonSerializerContext public static class Paths { - public readonly static AsciiString Json = "/json"; - public readonly static AsciiString Plaintext = "/plaintext"; - public readonly static AsciiString SingleQuery = "/db"; - public readonly static AsciiString Fortunes = "/fortunes"; - public readonly static AsciiString Updates = "/updates/"; - public readonly static AsciiString MultipleQueries = "/queries/"; - public readonly static AsciiString Caching = "/cached-worlds/"; + public static ReadOnlySpan Json => "/json"u8; + public static ReadOnlySpan Plaintext => "/plaintext"u8; + public static ReadOnlySpan SingleQuery => "/db"u8; + public static ReadOnlySpan Fortunes => "/fortunes"u8; + public static ReadOnlySpan Updates => "/updates/"u8; + public static ReadOnlySpan MultipleQueries => "/queries/"u8; + public static ReadOnlySpan Caching => "/cached-worlds/"u8; } private RequestType _requestType; @@ -169,11 +169,11 @@ private static Task Default(PipeWriter pipeWriter) return Task.CompletedTask; } #endif - private readonly static AsciiString _defaultPreamble = - _http11NotFound + - _headerServer + _crlf + - _headerContentTypeText + _crlf + - _headerContentLengthZero; + private static ReadOnlySpan _defaultPreamble => + "HTTP/1.1 200 OK\r\n"u8 + + "Server: K"u8 + "\r\n"u8 + + "Content-Type: text/plain"u8 + + "Content-Length: 0"u8; private static void Default(ref BufferWriter writer) { diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/CachedWorld.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/CachedWorld.cs index 61910b95587..fc59d5c17f0 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/CachedWorld.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/CachedWorld.cs @@ -9,5 +9,5 @@ public sealed class CachedWorld public int RandomNumber { get; set; } - public static implicit operator CachedWorld(World world) => new CachedWorld { Id = world.Id, RandomNumber = world.RandomNumber }; + public static implicit operator CachedWorld(World world) => new() { Id = world.Id, RandomNumber = world.RandomNumber }; } diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/DateHeader.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/DateHeader.cs index 9e768ad1f53..e582787bbd7 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/DateHeader.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/DateHeader.cs @@ -57,9 +57,7 @@ private static void SetDateValues(DateTimeOffset value) throw new Exception("date time format failed"); } Debug.Assert(written == dateTimeRLength); - var temp = s_headerBytesMaster; - s_headerBytesMaster = s_headerBytesScratch; - s_headerBytesScratch = temp; + (s_headerBytesScratch, s_headerBytesMaster) = (s_headerBytesMaster, s_headerBytesScratch); } } } diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/PlatformBenchmarks.csproj b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/PlatformBenchmarks.csproj index 864d57f1676..951819f4c3a 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/PlatformBenchmarks.csproj +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/PlatformBenchmarks.csproj @@ -1,9 +1,10 @@  - net6.0 + net7.0 Exe true enable + true diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Program.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Program.cs index d684abb40e8..c47f2d3b679 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Program.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Program.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Runtime.InteropServices; +using System.Text; namespace PlatformBenchmarks; @@ -13,15 +14,15 @@ public static async Task Main(string[] args) { Args = args; - Console.WriteLine(BenchmarkApplication.ApplicationName); + Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.ApplicationName)); #if !DATABASE - Console.WriteLine(BenchmarkApplication.Paths.Plaintext); - Console.WriteLine(BenchmarkApplication.Paths.Json); + Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.Plaintext)); + Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.Json)); #else - Console.WriteLine(BenchmarkApplication.Paths.Fortunes); - Console.WriteLine(BenchmarkApplication.Paths.SingleQuery); - Console.WriteLine(BenchmarkApplication.Paths.Updates); - Console.WriteLine(BenchmarkApplication.Paths.MultipleQueries); + Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.Fortunes)); + Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.SingleQuery)); + Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.Updates)); + Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.MultipleQueries)); #endif DateHeader.SyncDateTimer(); diff --git a/frameworks/CSharp/aspnetcore/aspcore-ado-my.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-ado-my.dockerfile index 3cdaa161421..d9e34c43f69 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-ado-my.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-ado-my.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY PlatformBenchmarks . RUN dotnet publish -c Release -o out /p:DatabaseProvider=MySqlConnector -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-ado-pg-up.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-ado-pg-up.dockerfile index f1c909b8f3a..ef3297a9aa1 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-ado-pg-up.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-ado-pg-up.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY PlatformBenchmarks . RUN dotnet publish -c Release -o out /p:DatabaseProvider=Npgsql -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-ado-pg.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-ado-pg.dockerfile index d197b0a28da..63ddf4c2eeb 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-ado-pg.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-ado-pg.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY PlatformBenchmarks . RUN dotnet publish -c Release -o out /p:DatabaseProvider=Npgsql -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mvc-ado-my.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mvc-ado-my.dockerfile index 6ef8811f9d1..2f9d6cef23d 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mvc-ado-my.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mvc-ado-my.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mvc-ado-pg-up.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mvc-ado-pg-up.dockerfile index cb426c50006..49cd9671847 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mvc-ado-pg-up.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mvc-ado-pg-up.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mvc-ado-pg.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mvc-ado-pg.dockerfile index f72002d3976..88aaae4e4b5 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mvc-ado-pg.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mvc-ado-pg.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mvc-dap-my.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mvc-dap-my.dockerfile index 76e5651b0e7..460f7041203 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mvc-dap-my.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mvc-dap-my.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mvc-dap-pg-up.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mvc-dap-pg-up.dockerfile index a650b43bb06..dc0e735d22f 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mvc-dap-pg-up.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mvc-dap-pg-up.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mvc-dap-pg.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mvc-dap-pg.dockerfile index 6d16b107c51..4ab66ce7dc0 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mvc-dap-pg.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mvc-dap-pg.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mvc-ef-pg.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mvc-ef-pg.dockerfile index 3a16dee60b8..d972d3f4f0a 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mvc-ef-pg.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mvc-ef-pg.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mvc.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mvc.dockerfile index e2e5fb7f7f1..c02dc68281a 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mvc.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mvc.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mw-ado-my.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mw-ado-my.dockerfile index f3a96a54ae5..1648f0d6223 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mw-ado-my.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mw-ado-my.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mw-ado-pg-up.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mw-ado-pg-up.dockerfile index c514f7acabf..a217244bfea 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mw-ado-pg-up.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mw-ado-pg-up.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mw-ado-pg.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mw-ado-pg.dockerfile index 29461717b13..43380a14e32 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mw-ado-pg.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mw-ado-pg.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mw-dap-my.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mw-dap-my.dockerfile index eb26af890d9..d97decf292a 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mw-dap-my.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mw-dap-my.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mw-dap-pg-up.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mw-dap-pg-up.dockerfile index ce55a85ce0d..178256f5e0f 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mw-dap-pg-up.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mw-dap-pg-up.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mw-dap-pg.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mw-dap-pg.dockerfile index 7b77884fbac..8b2cf7fb26a 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mw-dap-pg.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mw-dap-pg.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mw-ef-pg.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mw-ef-pg.dockerfile index bfa09e592e7..875a9045a44 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mw-ef-pg.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mw-ef-pg.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mw-json.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mw-json.dockerfile index 67096993685..113babbc939 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mw-json.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mw-json.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore-mw.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-mw.dockerfile index 0eb81c500af..4c2b45199ce 100644 --- a/frameworks/CSharp/aspnetcore/aspcore-mw.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore-mw.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 # Full PGO diff --git a/frameworks/CSharp/aspnetcore/aspcore.dockerfile b/frameworks/CSharp/aspnetcore/aspcore.dockerfile index ef309958311..e7b1aaa550e 100644 --- a/frameworks/CSharp/aspnetcore/aspcore.dockerfile +++ b/frameworks/CSharp/aspnetcore/aspcore.dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build WORKDIR /app COPY PlatformBenchmarks . RUN dotnet publish -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime ENV ASPNETCORE_URLS http://+:8080 ENV DOTNET_SYSTEM_NET_SOCKETS_INLINE_COMPLETIONS 1 From bec2f230873e4d2a237ec108604aefac5b99d756 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Mon, 14 Nov 2022 18:47:21 +0000 Subject: [PATCH 2/7] Apply suggestions from code review Co-authored-by: Eric Erhardt --- .../PlatformBenchmarks/BenchmarkApplication.Fortunes.cs | 4 ++-- .../PlatformBenchmarks/BenchmarkApplication.Json.cs | 4 ++-- .../aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Fortunes.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Fortunes.cs index ee9e94ff12f..5d951303e0b 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Fortunes.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Fortunes.cs @@ -14,8 +14,8 @@ public partial class BenchmarkApplication { private static ReadOnlySpan _fortunesPreamble => "HTTP/1.1 200 OK\r\n"u8 + - "Server: K"u8 + "\r\n"u8 + - "Content-Type: text/html; charset=UTF-8"u8 + "\r\n"u8 + + "Server: K\r\n"u8 + + "Content-Type: text/html; charset=UTF-8\r\n"u8 + "Content-Length: "u8; private async Task Fortunes(PipeWriter pipeWriter) diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Json.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Json.cs index 42df639c24a..ad213dfabe7 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Json.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Json.cs @@ -12,8 +12,8 @@ public partial class BenchmarkApplication private static ReadOnlySpan _jsonPreamble => "HTTP/1.1 200 OK\r\n"u8 + - "Server: K"u8 + "\r\n"u8 + - "Content-Type: application/json"u8 + "\r\n"u8 + + "Server: K\r\n"u8 + + "Content-Type: application/json\r\n"u8 + "Content-Length: 27"u8; private static void Json(ref BufferWriter writer, IBufferWriter bodyWriter) diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs index 2ff1b8157e0..8295bbf6538 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs @@ -14,8 +14,7 @@ namespace PlatformBenchmarks; public partial class BenchmarkApplication { - private static ReadOnlySpan _applicationName => "Kestrel Platform-Level Application"u8; - public static ReadOnlySpan ApplicationName => _applicationName; + public static ReadOnlySpan ApplicationName => "Kestrel Platform-Level Application"u8; private static ReadOnlySpan _crlf => "\r\n"u8; private static ReadOnlySpan _eoh => "\r\n\r\n"u8; // End Of Headers From 2e552d543679be7942229a20aa618f97787c65b3 Mon Sep 17 00:00:00 2001 From: benaadams Date: Tue, 15 Nov 2022 08:05:54 +0000 Subject: [PATCH 3/7] Feedback --- frameworks/CSharp/aspnetcore/PlatformBenchmarks/DateHeader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/DateHeader.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/DateHeader.cs index e582787bbd7..89e951f2d9f 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/DateHeader.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/DateHeader.cs @@ -27,7 +27,7 @@ internal static class DateHeader static DateHeader() { - var utf8 = Encoding.ASCII.GetBytes("\r\nDate: ").AsSpan(); + var utf8 = "\r\nDate: "u8; utf8.CopyTo(s_headerBytesMaster); utf8.CopyTo(s_headerBytesScratch); From 0a42dd26cec19adf2fd2ba85133727e1de70384f Mon Sep 17 00:00:00 2001 From: benaadams Date: Tue, 15 Nov 2022 09:44:11 +0000 Subject: [PATCH 4/7] Seal classes --- .../aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs | 2 +- .../aspnetcore/PlatformBenchmarks/Data/BatchUpdateString.cs | 2 +- .../PlatformBenchmarks/Data/Providers/RawDbMySqlConnector.cs | 2 +- .../aspnetcore/PlatformBenchmarks/Data/Providers/RawDbNpgsql.cs | 2 +- frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/Random.cs | 2 +- .../CSharp/aspnetcore/PlatformBenchmarks/HttpApplication.cs | 2 +- frameworks/CSharp/aspnetcore/PlatformBenchmarks/Program.cs | 2 +- frameworks/CSharp/aspnetcore/PlatformBenchmarks/Startup.cs | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs index 8295bbf6538..627faed5dca 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs @@ -12,7 +12,7 @@ namespace PlatformBenchmarks; -public partial class BenchmarkApplication +public sealed partial class BenchmarkApplication { public static ReadOnlySpan ApplicationName => "Kestrel Platform-Level Application"u8; diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/BatchUpdateString.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/BatchUpdateString.cs index 9eb7ff4edfa..39777801b5d 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/BatchUpdateString.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/BatchUpdateString.cs @@ -3,7 +3,7 @@ namespace PlatformBenchmarks; -internal class BatchUpdateString +internal sealed class BatchUpdateString { private const int MaxBatch = 500; diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/Providers/RawDbMySqlConnector.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/Providers/RawDbMySqlConnector.cs index 0a0a27559de..45cbc27e64c 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/Providers/RawDbMySqlConnector.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/Providers/RawDbMySqlConnector.cs @@ -15,7 +15,7 @@ namespace PlatformBenchmarks { // Is semantically identical to RawDbNpgsql.cs. // If you are changing RawDbMySqlConnector.cs, also consider changing RawDbNpgsql.cs. - public class RawDb + public sealed class RawDb { private readonly ConcurrentRandom _random; private readonly string _connectionString; diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/Providers/RawDbNpgsql.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/Providers/RawDbNpgsql.cs index 96391492ba8..024a8bb2b23 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/Providers/RawDbNpgsql.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/Providers/RawDbNpgsql.cs @@ -15,7 +15,7 @@ namespace PlatformBenchmarks { // Is semantically identical to RawDbMySqlConnector.cs. // If you are changing RawDbNpgsql.cs, also consider changing RawDbMySqlConnector.cs. - public class RawDb + public sealed class RawDb { private readonly ConcurrentRandom _random; private readonly string _connectionString; diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/Random.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/Random.cs index c5c634a2723..520500157b2 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/Random.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/Random.cs @@ -5,7 +5,7 @@ namespace PlatformBenchmarks; -public class ConcurrentRandom +public sealed class ConcurrentRandom { private static int nextSeed = 0; diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/HttpApplication.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/HttpApplication.cs index bed4e9de36a..d82368e15a3 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/HttpApplication.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/HttpApplication.cs @@ -14,7 +14,7 @@ public static class HttpApplicationConnectionBuilderExtensions } } -public class HttpApplication where TConnection : IHttpConnection, new() +public sealed class HttpApplication where TConnection : IHttpConnection, new() { public Task ExecuteAsync(ConnectionContext connection) { diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Program.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Program.cs index c47f2d3b679..5db336614c4 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Program.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Program.cs @@ -6,7 +6,7 @@ namespace PlatformBenchmarks; -public class Program +public sealed class Program { public static string[] Args; diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Startup.cs b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Startup.cs index 640f7a3d86d..069fe381a42 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Startup.cs +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/Startup.cs @@ -3,7 +3,7 @@ namespace PlatformBenchmarks; -public class Startup +public sealed class Startup { public void Configure(IApplicationBuilder app) { From 11f90e44c8fcb45a12b7ea1a8c3d4e7eae352682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Mon, 21 Nov 2022 15:48:46 +0900 Subject: [PATCH 5/7] Add PublishAot configurations --- .../PlatformBenchmarks.csproj | 7 +++ .../aspcore-aot-ado-pg-up.dockerfile | 17 ++++++ .../aspnetcore/aspcore-aot-ado-pg.dockerfile | 17 ++++++ .../CSharp/aspnetcore/aspcore-aot.dockerfile | 18 ++++++ .../CSharp/aspnetcore/benchmark_config.json | 58 +++++++++++++++++++ frameworks/CSharp/aspnetcore/config.toml | 40 +++++++++++++ 6 files changed, 157 insertions(+) create mode 100644 frameworks/CSharp/aspnetcore/aspcore-aot-ado-pg-up.dockerfile create mode 100644 frameworks/CSharp/aspnetcore/aspcore-aot-ado-pg.dockerfile create mode 100644 frameworks/CSharp/aspnetcore/aspcore-aot.dockerfile diff --git a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/PlatformBenchmarks.csproj b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/PlatformBenchmarks.csproj index 951819f4c3a..8a683cee525 100644 --- a/frameworks/CSharp/aspnetcore/PlatformBenchmarks/PlatformBenchmarks.csproj +++ b/frameworks/CSharp/aspnetcore/PlatformBenchmarks/PlatformBenchmarks.csproj @@ -4,7 +4,14 @@ Exe true enable + + true + + + true + Speed + true diff --git a/frameworks/CSharp/aspnetcore/aspcore-aot-ado-pg-up.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-aot-ado-pg-up.dockerfile new file mode 100644 index 00000000000..d3b548ae07c --- /dev/null +++ b/frameworks/CSharp/aspnetcore/aspcore-aot-ado-pg-up.dockerfile @@ -0,0 +1,17 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build +RUN apt-get update +RUN apt-get -yqq install clang zlib1g-dev +WORKDIR /app +COPY PlatformBenchmarks . +RUN dotnet publish -c Release -o out -p:PublishAot=true -p:DatabaseProvider=Npgsql + +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime +ENV ASPNETCORE_URLS http://+:8080 + +WORKDIR /app +COPY --from=build /app/out ./ +COPY PlatformBenchmarks/appsettings.postgresql.updates.json ./appsettings.json + +EXPOSE 8080 + +ENTRYPOINT ["./PlatformBenchmarks"] diff --git a/frameworks/CSharp/aspnetcore/aspcore-aot-ado-pg.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-aot-ado-pg.dockerfile new file mode 100644 index 00000000000..ad71cca0d14 --- /dev/null +++ b/frameworks/CSharp/aspnetcore/aspcore-aot-ado-pg.dockerfile @@ -0,0 +1,17 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build +RUN apt-get update +RUN apt-get -yqq install clang zlib1g-dev +WORKDIR /app +COPY PlatformBenchmarks . +RUN dotnet publish -c Release -o out -p:PublishAot=true -p:DatabaseProvider=Npgsql + +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime +ENV ASPNETCORE_URLS http://+:8080 + +WORKDIR /app +COPY --from=build /app/out ./ +COPY PlatformBenchmarks/appsettings.postgresql.json ./appsettings.json + +EXPOSE 8080 + +ENTRYPOINT ["./PlatformBenchmarks"] diff --git a/frameworks/CSharp/aspnetcore/aspcore-aot.dockerfile b/frameworks/CSharp/aspnetcore/aspcore-aot.dockerfile new file mode 100644 index 00000000000..1a16e8f6c25 --- /dev/null +++ b/frameworks/CSharp/aspnetcore/aspcore-aot.dockerfile @@ -0,0 +1,18 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build +RUN apt-get update +RUN apt-get -yqq install clang zlib1g-dev +WORKDIR /app +COPY PlatformBenchmarks . +RUN dotnet publish -c Release -o out -p:PublishAot=true + +FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime +ENV ASPNETCORE_URLS http://+:8080 +ENV DOTNET_SYSTEM_NET_SOCKETS_INLINE_COMPLETIONS 1 + +WORKDIR /app +COPY --from=build /app/out ./ +COPY Benchmarks/appsettings.json ./appsettings.json + +EXPOSE 8080 + +ENTRYPOINT ["./PlatformBenchmarks"] diff --git a/frameworks/CSharp/aspnetcore/benchmark_config.json b/frameworks/CSharp/aspnetcore/benchmark_config.json index b742c109df2..0487405dc30 100644 --- a/frameworks/CSharp/aspnetcore/benchmark_config.json +++ b/frameworks/CSharp/aspnetcore/benchmark_config.json @@ -20,6 +20,25 @@ "notes": "", "versus": "aspcore" }, + "aot": { + "plaintext_url": "/plaintext", + "json_url": "/json", + "port": 8080, + "approach": "Realistic", + "classification": "Platform", + "database": "None", + "framework": "ASP.NET Core", + "language": "C#", + "orm": "Raw", + "platform": ".NET", + "flavor": "NativeAOT", + "webserver": "Kestrel", + "os": "Linux", + "database_os": "Linux", + "display_name": "ASP.NET Core [Platform, NativeAOT]", + "notes": "", + "versus": "aspcore-aot" + }, "ado-pg": { "fortune_url": "/fortunes", "db_url": "/db", @@ -41,6 +60,27 @@ "notes": "", "versus": "aspcore-ado-pg" }, + "aot-ado-pg": { + "fortune_url": "/fortunes", + "db_url": "/db", + "query_url": "/queries/", + "cached_query_url": "/cached-worlds/", + "port": 8080, + "approach": "Realistic", + "classification": "Platform", + "database": "Postgres", + "framework": "ASP.NET Core", + "language": "C#", + "orm": "Raw", + "platform": ".NET", + "flavor": "NativeAOT", + "webserver": "Kestrel", + "os": "Linux", + "database_os": "Linux", + "display_name": "ASP.NET Core [Platform, NativeAOT, Pg]", + "notes": "", + "versus": "aspcore-aot-ado-pg" + }, "ado-pg-up": { "update_url": "/updates/", "port": 8080, @@ -59,6 +99,24 @@ "notes": "", "versus": "aspcore-ado-pg-up" }, + "aot-ado-pg-up": { + "update_url": "/updates/", + "port": 8080, + "approach": "Realistic", + "classification": "Platform", + "database": "Postgres", + "framework": "ASP.NET Core", + "language": "C#", + "orm": "Raw", + "platform": ".NET", + "flavor": "NativeAOT", + "webserver": "Kestrel", + "os": "Linux", + "database_os": "Linux", + "display_name": "ASP.NET Core [Platform, NativeAOT, Pg]", + "notes": "", + "versus": "aspcore-aot-ado-pg-up" + }, "mw": { "plaintext_url": "/plaintext", "port": 8080, diff --git a/frameworks/CSharp/aspnetcore/config.toml b/frameworks/CSharp/aspnetcore/config.toml index 8535741d8a8..42cb9e5d20a 100644 --- a/frameworks/CSharp/aspnetcore/config.toml +++ b/frameworks/CSharp/aspnetcore/config.toml @@ -16,6 +16,21 @@ platform = ".NET" webserver = "Kestrel" versus = "aspcore-ado-pg" +[aot-ado-pg] +urls.db = "/db" +urls.query = "/queries/" +urls.fortune = "/fortunes" +urls.cached_query = "/cached-worlds/" +approach = "Realistic" +classification = "Platform" +database = "Postgres" +database_os = "Linux" +os = "Linux" +orm = "Raw" +platform = ".NET" +webserver = "Kestrel" +versus = "aspcore-aot-ado-pg" + [ado-my] urls.db = "/db" urls.query = "/queries/" @@ -262,6 +277,19 @@ platform = ".NET" webserver = "Kestrel" versus = "aspcore" +[aot] +urls.plaintext = "/plaintext" +urls.json = "/json" +approach = "Realistic" +classification = "Platform" +database = "None" +database_os = "Linux" +os = "Linux" +orm = "Raw" +platform = ".NET" +webserver = "Kestrel" +versus = "aspcore-aot" + [mvc-dap-pg-up] urls.update = "/mvc/updates/dapper?queries=" approach = "Realistic" @@ -309,3 +337,15 @@ orm = "Raw" platform = ".NET" webserver = "Kestrel" versus = "aspcore-ado-pg-up" + +[aot-ado-pg-up] +urls.update = "/updates/" +approach = "Realistic" +classification = "Platform" +database = "Postgres" +database_os = "Linux" +os = "Linux" +orm = "Raw" +platform = ".NET" +webserver = "Kestrel" +versus = "aspcore-ado-pg-up" From 870777237d0cbe2ac96c42ec7840c3ea9c494c7a Mon Sep 17 00:00:00 2001 From: benaadams Date: Mon, 21 Nov 2022 11:32:27 +0000 Subject: [PATCH 6/7] Remove corert --- .../CSharp/aspnetcore-corert/.gitignore | 38 --- .../PlatformBenchmarks/AsciiString.cs | 57 ---- .../BenchmarkApplication.Caching.cs | 19 -- .../BenchmarkApplication.Fortunes.cs | 57 ---- .../BenchmarkApplication.HttpConnection.cs | 295 ------------------ .../BenchmarkApplication.Json.cs | 34 -- .../BenchmarkApplication.MultipleQueries.cs | 46 --- .../BenchmarkApplication.Plaintext.cs | 24 -- .../BenchmarkApplication.SingleQuery.cs | 45 --- .../BenchmarkApplication.Updates.cs | 45 --- .../BenchmarkApplication.cs | 197 ------------ .../BenchmarkConfigurationHelpers.cs | 58 ---- .../PlatformBenchmarks/BufferExtensions.cs | 62 ---- .../PlatformBenchmarks/BufferWriter.cs | 141 --------- .../Configuration/AppSettings.cs | 11 - .../Configuration/DatabaseServer.cs | 12 - .../Data/BatchUpdateString.cs | 41 --- .../PlatformBenchmarks/Data/CachedWorld.cs | 13 - .../PlatformBenchmarks/Data/Fortune.cs | 22 -- .../PlatformBenchmarks/Data/JsonMessage.cs | 9 - .../Data/Providers/RawDbMySqlConnector.cs | 272 ---------------- .../Data/Providers/RawDbNpgsql.cs | 265 ---------------- .../PlatformBenchmarks/Data/Random.cs | 29 -- .../PlatformBenchmarks/Data/World.cs | 14 - .../PlatformBenchmarks/DateHeader.cs | 65 ---- .../PlatformBenchmarks/HttpApplication.cs | 28 -- .../PlatformBenchmarks/IHttpConnection.cs | 14 - .../PlatformBenchmarks/NuGet.Config | 8 - .../PlatformBenchmarks.csproj | 40 --- .../PlatformBenchmarks/Program.cs | 90 ------ .../PlatformBenchmarks/Startup.cs | 11 - .../PlatformBenchmarks/StringBuilderCache.cs | 57 ---- .../PlatformBenchmarks/appsettings.json | 3 - .../PlatformBenchmarks/appsettings.mysql.json | 4 - .../appsettings.postgresql.json | 4 - .../appsettings.postgresql.updates.json | 4 - frameworks/CSharp/aspnetcore-corert/README.md | 28 -- .../aspcore-corert-ado-pg-up.dockerfile | 17 - .../aspcore-corert-ado-pg.dockerfile | 17 - .../aspcore-corert.dockerfile | 16 - .../aspnetcore-corert/benchmark_config.json | 63 ---- .../CSharp/aspnetcore-corert/config.toml | 42 --- 42 files changed, 2317 deletions(-) delete mode 100644 frameworks/CSharp/aspnetcore-corert/.gitignore delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/AsciiString.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Caching.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Fortunes.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.HttpConnection.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Json.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.MultipleQueries.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Plaintext.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.SingleQuery.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Updates.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkConfigurationHelpers.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BufferExtensions.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BufferWriter.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Configuration/AppSettings.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Configuration/DatabaseServer.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/BatchUpdateString.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/CachedWorld.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Fortune.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/JsonMessage.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Providers/RawDbMySqlConnector.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Providers/RawDbNpgsql.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Random.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/World.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/DateHeader.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/HttpApplication.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/IHttpConnection.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/NuGet.Config delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/PlatformBenchmarks.csproj delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Program.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Startup.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/StringBuilderCache.cs delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.json delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.mysql.json delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.postgresql.json delete mode 100644 frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.postgresql.updates.json delete mode 100644 frameworks/CSharp/aspnetcore-corert/README.md delete mode 100644 frameworks/CSharp/aspnetcore-corert/aspcore-corert-ado-pg-up.dockerfile delete mode 100644 frameworks/CSharp/aspnetcore-corert/aspcore-corert-ado-pg.dockerfile delete mode 100644 frameworks/CSharp/aspnetcore-corert/aspcore-corert.dockerfile delete mode 100644 frameworks/CSharp/aspnetcore-corert/benchmark_config.json delete mode 100644 frameworks/CSharp/aspnetcore-corert/config.toml diff --git a/frameworks/CSharp/aspnetcore-corert/.gitignore b/frameworks/CSharp/aspnetcore-corert/.gitignore deleted file mode 100644 index e6a1c7ee52b..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/.gitignore +++ /dev/null @@ -1,38 +0,0 @@ -[Oo]bj/ -[Bb]in/ -[Oo]ut/ -TestResults/ -.nuget/ -*.sln.ide/ -_ReSharper.*/ -.idea/ -packages/ -artifacts/ -PublishProfiles/ -.vs/ -*.user -*.suo -*.cache -*.docstates -_ReSharper.* -nuget.exe -*net45.csproj -*net451.csproj -*k10.csproj -*.psess -*.vsp -*.pidb -*.userprefs -*DS_Store -*.ncrunchsolution -*.*sdf -*.ipch -*.swp -*~ -.build/ -.testPublish/ -launchSettings.json -BenchmarkDotNet.Artifacts/ -BDN.Generated/ -binaries/ -global.json diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/AsciiString.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/AsciiString.cs deleted file mode 100644 index 34c4a0f0adb..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/AsciiString.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Text; - -namespace PlatformBenchmarks; - -public readonly struct AsciiString : IEquatable -{ - private readonly byte[] _data; - - public AsciiString(string s) => _data = Encoding.ASCII.GetBytes(s); - - private AsciiString(byte[] b) => _data = b; - - public int Length => _data.Length; - - public ReadOnlySpan AsSpan() => _data; - - public static implicit operator ReadOnlySpan(AsciiString str) => str._data; - public static implicit operator byte[](AsciiString str) => str._data; - - public static implicit operator AsciiString(string str) => new(str); - - public override string ToString() => Encoding.ASCII.GetString(_data); - public static explicit operator string(AsciiString str) => str.ToString(); - - public bool Equals(AsciiString other) => ReferenceEquals(_data, other._data) || SequenceEqual(_data, other._data); - private bool SequenceEqual(byte[] data1, byte[] data2) => new Span(data1).SequenceEqual(data2); - - public static bool operator ==(AsciiString a, AsciiString b) => a.Equals(b); - public static bool operator !=(AsciiString a, AsciiString b) => !a.Equals(b); - public override bool Equals(object other) => (other is AsciiString @string) && Equals(@string); - - public static AsciiString operator +(AsciiString a, AsciiString b) - { - var result = new byte[a.Length + b.Length]; - a._data.CopyTo(result, 0); - b._data.CopyTo(result, a.Length); - return new AsciiString(result); - } - - public override int GetHashCode() - { - // Copied from x64 version of string.GetLegacyNonRandomizedHashCode() - // https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/String.Comparison.cs - var data = _data; - int hash1 = 5381; - int hash2 = hash1; - foreach (int b in data) - { - hash1 = ((hash1 << 5) + hash1) ^ b; - } - return hash1 + (hash2 * 1566083941); - } - -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Caching.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Caching.cs deleted file mode 100644 index 96bec49e72b..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Caching.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if DATABASE - -using System.IO.Pipelines; -using System.Threading.Tasks; - -namespace PlatformBenchmarks; - -public partial class BenchmarkApplication -{ - private async Task Caching(PipeWriter pipeWriter, int count) - { - OutputMultipleQueries(pipeWriter, await Db.LoadCachedQueries(count), SerializerContext.CachedWorldArray); - } -} - -#endif \ No newline at end of file diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Fortunes.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Fortunes.cs deleted file mode 100644 index a60f6a3fc4a..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Fortunes.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if DATABASE - -using System.Collections.Generic; -using System.IO.Pipelines; -using System.Text.Encodings.Web; -using System.Threading.Tasks; - -namespace PlatformBenchmarks -{ - public partial class BenchmarkApplication - { - private readonly static AsciiString _fortunesPreamble = - _http11OK + - _headerServer + _crlf + - _headerContentTypeHtml + _crlf + - _headerContentLength; - - private async Task Fortunes(PipeWriter pipeWriter) - { - OutputFortunes(pipeWriter, await Db.LoadFortunesRows()); - } - - private void OutputFortunes(PipeWriter pipeWriter, List model) - { - var writer = GetWriter(pipeWriter, sizeHint: 1600); // in reality it's 1361 - - writer.Write(_fortunesPreamble); - - var lengthWriter = writer; - writer.Write(_contentLengthGap); - - // Date header - writer.Write(DateHeader.HeaderBytes); - - var bodyStart = writer.Buffered; - // Body - writer.Write(_fortunesTableStart); - foreach (var item in model) - { - writer.Write(_fortunesRowStart); - writer.WriteNumeric((uint)item.Id); - writer.Write(_fortunesColumn); - writer.WriteUtf8String(HtmlEncoder.Encode(item.Message)); - writer.Write(_fortunesRowEnd); - } - writer.Write(_fortunesTableEnd); - lengthWriter.WriteNumeric((uint)(writer.Buffered - bodyStart)); - - writer.Commit(); - } - } -} - -#endif \ No newline at end of file diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.HttpConnection.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.HttpConnection.cs deleted file mode 100644 index 1d3aa29c2e3..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.HttpConnection.cs +++ /dev/null @@ -1,295 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Buffers; -using System.IO.Pipelines; -using System.Runtime.CompilerServices; -using System.Text.Encodings.Web; -using System.Text.Unicode; -using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; - -namespace PlatformBenchmarks; - -public partial class BenchmarkApplication : IHttpConnection -{ - private State _state; - - public PipeReader Reader { get; set; } - public PipeWriter Writer { get; set; } - - protected HtmlEncoder HtmlEncoder { get; } = CreateHtmlEncoder(); - - private HttpParser Parser { get; } = new HttpParser(); - - public async Task ExecuteAsync() - { - try - { - await ProcessRequestsAsync(); - - Reader.Complete(); - } - catch (Exception ex) - { - Reader.Complete(ex); - } - finally - { - Writer.Complete(); - } - } - - private static HtmlEncoder CreateHtmlEncoder() - { - var settings = new TextEncoderSettings(UnicodeRanges.BasicLatin, UnicodeRanges.Katakana, UnicodeRanges.Hiragana); - settings.AllowCharacter('\u2014'); // allow EM DASH through - return HtmlEncoder.Create(settings); - } - -#if !DATABASE - private async Task ProcessRequestsAsync() - { - while (true) - { - var readResult = await Reader.ReadAsync(default); - var buffer = readResult.Buffer; - var isCompleted = readResult.IsCompleted; - - if (buffer.IsEmpty && isCompleted) - { - return; - } - - if (!HandleRequests(buffer, isCompleted)) - { - return; - } - - await Writer.FlushAsync(default); - } - } - - private bool HandleRequests(in ReadOnlySequence buffer, bool isCompleted) - { - var reader = new SequenceReader(buffer); - var writer = GetWriter(Writer, sizeHint: 160 * 16); // 160*16 is for Plaintext, for Json 160 would be enough - - while (true) - { - if (!ParseHttpRequest(ref reader, isCompleted)) - { - return false; - } - - if (_state == State.Body) - { - ProcessRequest(ref writer); - - _state = State.StartLine; - - if (!reader.End) - { - // More input data to parse - continue; - } - } - - // No more input or incomplete data, Advance the Reader - Reader.AdvanceTo(reader.Position, buffer.End); - break; - } - - writer.Commit(); - return true; - } - - private bool ParseHttpRequest(ref SequenceReader reader, bool isCompleted) - { - var state = _state; - - if (state == State.StartLine) - { - if (Parser.ParseRequestLine(new ParsingAdapter(this), ref reader)) - { - state = State.Headers; - } - } - - if (state == State.Headers) - { - var success = Parser.ParseHeaders(new ParsingAdapter(this), ref reader); - - if (success) - { - state = State.Body; - } - } - - if (state != State.Body && isCompleted) - { - ThrowUnexpectedEndOfData(); - } - - _state = state; - return true; - } -#else - private async Task ProcessRequestsAsync() - { - while (true) - { - var readResult = await Reader.ReadAsync(); - var buffer = readResult.Buffer; - var isCompleted = readResult.IsCompleted; - - if (buffer.IsEmpty && isCompleted) - { - return; - } - - while (true) - { - if (!ParseHttpRequest(ref buffer, isCompleted)) - { - return; - } - - if (_state == State.Body) - { - await ProcessRequestAsync(); - - _state = State.StartLine; - - if (!buffer.IsEmpty) - { - // More input data to parse - continue; - } - } - - // No more input or incomplete data, Advance the Reader - Reader.AdvanceTo(buffer.Start, buffer.End); - break; - } - - await Writer.FlushAsync(); - } - } - - private bool ParseHttpRequest(ref ReadOnlySequence buffer, bool isCompleted) - { - var reader = new SequenceReader(buffer); - var state = _state; - - if (state == State.StartLine) - { - if (Parser.ParseRequestLine(new ParsingAdapter(this), ref reader)) - { - state = State.Headers; - } - } - - if (state == State.Headers) - { - var success = Parser.ParseHeaders(new ParsingAdapter(this), ref reader); - - if (success) - { - state = State.Body; - } - } - - if (state != State.Body && isCompleted) - { - ThrowUnexpectedEndOfData(); - } - - _state = state; - - if (state == State.Body) - { - // Complete request read, consumed and examined are the same (length 0) - buffer = buffer.Slice(reader.Position, 0); - } - else - { - // In-complete request read, consumed is current position and examined is the remaining. - buffer = buffer.Slice(reader.Position); - } - - return true; - } -#endif - - public void OnStaticIndexedHeader(int index) - { - } - - public void OnStaticIndexedHeader(int index, ReadOnlySpan value) - { - } - - public void OnHeader(ReadOnlySpan name, ReadOnlySpan value) - { - } - - public void OnHeadersComplete(bool endStream) - { - } - - private static void ThrowUnexpectedEndOfData() - { - throw new InvalidOperationException("Unexpected end of data!"); - } - - private enum State - { - StartLine, - Headers, - Body - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static BufferWriter GetWriter(PipeWriter pipeWriter, int sizeHint) - => new(new WriterAdapter(pipeWriter), sizeHint); - - private struct WriterAdapter : IBufferWriter - { - public PipeWriter Writer; - - public WriterAdapter(PipeWriter writer) - => Writer = writer; - - public void Advance(int count) - => Writer.Advance(count); - - public Memory GetMemory(int sizeHint = 0) - => Writer.GetMemory(sizeHint); - - public Span GetSpan(int sizeHint = 0) - => Writer.GetSpan(sizeHint); - } - - private struct ParsingAdapter : IHttpRequestLineHandler, IHttpHeadersHandler - { - public BenchmarkApplication RequestHandler; - - public ParsingAdapter(BenchmarkApplication requestHandler) - => RequestHandler = requestHandler; - - public void OnStaticIndexedHeader(int index) - => RequestHandler.OnStaticIndexedHeader(index); - - public void OnStaticIndexedHeader(int index, ReadOnlySpan value) - => RequestHandler.OnStaticIndexedHeader(index, value); - - public void OnHeader(ReadOnlySpan name, ReadOnlySpan value) - => RequestHandler.OnHeader(name, value); - - public void OnHeadersComplete(bool endStream) - => RequestHandler.OnHeadersComplete(endStream); - - public void OnStartLine(HttpVersionAndMethod versionAndMethod, TargetOffsetPathLength targetPath, Span startLine) - => RequestHandler.OnStartLine(versionAndMethod, targetPath, startLine); - } -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Json.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Json.cs deleted file mode 100644 index 02835c67f35..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Json.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Buffers; -using System.Text.Json; - -namespace PlatformBenchmarks; - -public partial class BenchmarkApplication -{ - private readonly static uint _jsonPayloadSize = (uint)JsonSerializer.SerializeToUtf8Bytes(new JsonMessage { message = "Hello, World!" }, SerializerContext.JsonMessage).Length; - - private readonly static AsciiString _jsonPreamble = - _http11OK + - _headerServer + _crlf + - _headerContentTypeJson + _crlf + - _headerContentLength + _jsonPayloadSize.ToString(); - - private static void Json(ref BufferWriter writer, IBufferWriter bodyWriter) - { - writer.Write(_jsonPreamble); - - // Date header - writer.Write(DateHeader.HeaderBytes); - - writer.Commit(); - - Utf8JsonWriter utf8JsonWriter = t_writer ??= new Utf8JsonWriter(bodyWriter, new JsonWriterOptions { SkipValidation = true }); - utf8JsonWriter.Reset(bodyWriter); - - // Body - JsonSerializer.Serialize(utf8JsonWriter, new JsonMessage { message = "Hello, World!" }, SerializerContext.JsonMessage); - } -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.MultipleQueries.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.MultipleQueries.cs deleted file mode 100644 index 0febb09f015..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.MultipleQueries.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if DATABASE - -using System.IO.Pipelines; -using System.Text.Json; -using System.Text.Json.Serialization.Metadata; -using System.Threading.Tasks; - -namespace PlatformBenchmarks -{ - public partial class BenchmarkApplication - { - private async Task MultipleQueries(PipeWriter pipeWriter, int count) - { - OutputMultipleQueries(pipeWriter, await Db.LoadMultipleQueriesRows(count), SerializerContext.WorldArray); - } - - private static void OutputMultipleQueries(PipeWriter pipeWriter, TWorld[] rows, JsonTypeInfo jsonTypeInfo) - { - var writer = GetWriter(pipeWriter, sizeHint: 160 * rows.Length); // in reality it's 152 for one - - writer.Write(_dbPreamble); - - var lengthWriter = writer; - writer.Write(_contentLengthGap); - - // Date header - writer.Write(DateHeader.HeaderBytes); - - writer.Commit(); - - Utf8JsonWriter utf8JsonWriter = t_writer ??= new Utf8JsonWriter(pipeWriter, new JsonWriterOptions { SkipValidation = true }); - utf8JsonWriter.Reset(pipeWriter); - - // Body - JsonSerializer.Serialize(utf8JsonWriter, rows, jsonTypeInfo); - - // Content-Length - lengthWriter.WriteNumeric((uint)utf8JsonWriter.BytesCommitted); - } - } -} - -#endif \ No newline at end of file diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Plaintext.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Plaintext.cs deleted file mode 100644 index 809ef6b3741..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Plaintext.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace PlatformBenchmarks; - -public partial class BenchmarkApplication -{ - private readonly static AsciiString _plaintextPreamble = - _http11OK + - _headerServer + _crlf + - _headerContentTypeText + _crlf + - _headerContentLength + _plainTextBody.Length.ToString(); - - private static void PlainText(ref BufferWriter writer) - { - writer.Write(_plaintextPreamble); - - // Date header - writer.Write(DateHeader.HeaderBytes); - - // Body - writer.Write(_plainTextBody); - } -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.SingleQuery.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.SingleQuery.cs deleted file mode 100644 index 102cafd907c..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.SingleQuery.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if DATABASE - -using System.IO.Pipelines; -using System.Text.Json; -using System.Threading.Tasks; - -namespace PlatformBenchmarks -{ - public partial class BenchmarkApplication - { - private async Task SingleQuery(PipeWriter pipeWriter) - { - OutputSingleQuery(pipeWriter, await Db.LoadSingleQueryRow()); - } - - private static void OutputSingleQuery(PipeWriter pipeWriter, World row) - { - var writer = GetWriter(pipeWriter, sizeHint: 180); // in reality it's 150 - - writer.Write(_dbPreamble); - - var lengthWriter = writer; - writer.Write(_contentLengthGap); - - // Date header - writer.Write(DateHeader.HeaderBytes); - - writer.Commit(); - - Utf8JsonWriter utf8JsonWriter = t_writer ??= new Utf8JsonWriter(pipeWriter, new JsonWriterOptions { SkipValidation = true }); - utf8JsonWriter.Reset(pipeWriter); - - // Body - JsonSerializer.Serialize(utf8JsonWriter, row, SerializerContext.World); - - // Content-Length - lengthWriter.WriteNumeric((uint)utf8JsonWriter.BytesCommitted); - } - } -} - -#endif \ No newline at end of file diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Updates.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Updates.cs deleted file mode 100644 index 2cdc4083c4f..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.Updates.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if DATABASE - -using System.IO.Pipelines; -using System.Text.Json; -using System.Threading.Tasks; - -namespace PlatformBenchmarks -{ - public partial class BenchmarkApplication - { - private async Task Updates(PipeWriter pipeWriter, int count) - { - OutputUpdates(pipeWriter, await Db.LoadMultipleUpdatesRows(count)); - } - - private static void OutputUpdates(PipeWriter pipeWriter, World[] rows) - { - var writer = GetWriter(pipeWriter, sizeHint: 120 * rows.Length); // in reality it's 112 for one - - writer.Write(_dbPreamble); - - var lengthWriter = writer; - writer.Write(_contentLengthGap); - - // Date header - writer.Write(DateHeader.HeaderBytes); - - writer.Commit(); - - Utf8JsonWriter utf8JsonWriter = t_writer ??= new Utf8JsonWriter(pipeWriter, new JsonWriterOptions { SkipValidation = true }); - utf8JsonWriter.Reset(pipeWriter); - - // Body - JsonSerializer.Serialize( utf8JsonWriter, rows, SerializerContext.WorldArray); - - // Content-Length - lengthWriter.WriteNumeric((uint)utf8JsonWriter.BytesCommitted); - } - } -} - -#endif \ No newline at end of file diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.cs deleted file mode 100644 index b6a78f227d9..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.cs +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Buffers.Text; -using System.IO.Pipelines; -using System.Text.Json; -using System.Text.Json.Serialization; -using System.Threading.Tasks; - -using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; - -namespace PlatformBenchmarks; - -public partial class BenchmarkApplication -{ - private readonly static AsciiString _applicationName = "Kestrel Platform-Level Application"; - public static AsciiString ApplicationName => _applicationName; - - private readonly static AsciiString _crlf = "\r\n"; - private readonly static AsciiString _eoh = "\r\n\r\n"; // End Of Headers - private readonly static AsciiString _http11OK = "HTTP/1.1 200 OK\r\n"; - private readonly static AsciiString _http11NotFound = "HTTP/1.1 404 Not Found\r\n"; - private readonly static AsciiString _headerServer = "Server: K"; - private readonly static AsciiString _headerContentLength = "Content-Length: "; - private readonly static AsciiString _headerContentLengthZero = "Content-Length: 0"; - private readonly static AsciiString _headerContentTypeText = "Content-Type: text/plain"; - private readonly static AsciiString _headerContentTypeJson = "Content-Type: application/json"; - private readonly static AsciiString _headerContentTypeHtml = "Content-Type: text/html; charset=UTF-8"; - - private readonly static AsciiString _dbPreamble = - _http11OK + - _headerServer + _crlf + - _headerContentTypeJson + _crlf + - _headerContentLength; - - private readonly static AsciiString _plainTextBody = "Hello, World!"; - - private static readonly JsonContext SerializerContext = JsonContext.Default; - - [JsonSourceGenerationOptions(GenerationMode = JsonSourceGenerationMode.Serialization, PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)] - [JsonSerializable(typeof(JsonMessage))] - [JsonSerializable(typeof(CachedWorld[]))] - [JsonSerializable(typeof(World[]))] - private sealed partial class JsonContext : JsonSerializerContext - { - } - - private readonly static AsciiString _fortunesTableStart = "Fortunes"; - private readonly static AsciiString _fortunesRowStart = ""; - private readonly static AsciiString _fortunesTableEnd = "
idmessage
"; - private readonly static AsciiString _fortunesColumn = ""; - private readonly static AsciiString _fortunesRowEnd = "
"; - private readonly static AsciiString _contentLengthGap = new string(' ', 4); - -#if DATABASE - public static RawDb Db { get; set; } -#endif - - [ThreadStatic] - private static Utf8JsonWriter t_writer; - - public static class Paths - { - public readonly static AsciiString Json = "/json"; - public readonly static AsciiString Plaintext = "/plaintext"; - public readonly static AsciiString SingleQuery = "/db"; - public readonly static AsciiString Fortunes = "/fortunes"; - public readonly static AsciiString Updates = "/updates/"; - public readonly static AsciiString MultipleQueries = "/queries/"; - public readonly static AsciiString Caching = "/cached-worlds/"; - } - - private RequestType _requestType; - private int _queries; - - public void OnStartLine(HttpVersionAndMethod versionAndMethod, TargetOffsetPathLength targetPath, Span startLine) - { - _requestType = versionAndMethod.Method == Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpMethod.Get ? GetRequestType(startLine.Slice(targetPath.Offset, targetPath.Length), ref _queries) : RequestType.NotRecognized; - } - - private RequestType GetRequestType(ReadOnlySpan path, ref int queries) - { -#if !DATABASE - if (path.Length == 10 && path.SequenceEqual(Paths.Plaintext)) - { - return RequestType.PlainText; - } - else if (path.Length == 5 && path.SequenceEqual(Paths.Json)) - { - return RequestType.Json; - } -#else - if (path.Length == 3 && path[0] == '/' && path[1] == 'd' && path[2] == 'b') - { - return RequestType.SingleQuery; - } - else if (path.Length == 9 && path[1] == 'f' && path.SequenceEqual(Paths.Fortunes)) - { - return RequestType.Fortunes; - } - else if (path.Length >= 15 && path[1] == 'c' && path.StartsWith(Paths.Caching)) - { - queries = ParseQueries(path.Slice(15)); - return RequestType.Caching; - } - else if (path.Length >= 9 && path[1] == 'u' && path.StartsWith(Paths.Updates)) - { - queries = ParseQueries(path.Slice(9)); - return RequestType.Updates; - } - else if (path.Length >= 9 && path[1] == 'q' && path.StartsWith(Paths.MultipleQueries)) - { - queries = ParseQueries(path.Slice(9)); - return RequestType.MultipleQueries; - } -#endif - return RequestType.NotRecognized; - } - - -#if !DATABASE - private void ProcessRequest(ref BufferWriter writer) - { - if (_requestType == RequestType.PlainText) - { - PlainText(ref writer); - } - else if (_requestType == RequestType.Json) - { - Json(ref writer, Writer); - } - else - { - Default(ref writer); - } - } -#else - - private static int ParseQueries(ReadOnlySpan parameter) - { - if (!Utf8Parser.TryParse(parameter, out int queries, out _) || queries < 1) - { - queries = 1; - } - else if (queries > 500) - { - queries = 500; - } - - return queries; - } - - private Task ProcessRequestAsync() => _requestType switch - { - RequestType.Fortunes => Fortunes(Writer), - RequestType.SingleQuery => SingleQuery(Writer), - RequestType.Caching => Caching(Writer, _queries), - RequestType.Updates => Updates(Writer, _queries), - RequestType.MultipleQueries => MultipleQueries(Writer, _queries), - _ => Default(Writer) - }; - - private static Task Default(PipeWriter pipeWriter) - { - var writer = GetWriter(pipeWriter, sizeHint: _defaultPreamble.Length + DateHeader.HeaderBytes.Length); - Default(ref writer); - writer.Commit(); - return Task.CompletedTask; - } -#endif - private readonly static AsciiString _defaultPreamble = - _http11NotFound + - _headerServer + _crlf + - _headerContentTypeText + _crlf + - _headerContentLengthZero; - - private static void Default(ref BufferWriter writer) - { - writer.Write(_defaultPreamble); - - // Date header - writer.Write(DateHeader.HeaderBytes); - } - - private enum RequestType - { - NotRecognized, - PlainText, - Json, - Fortunes, - SingleQuery, - Caching, - Updates, - MultipleQueries - } -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkConfigurationHelpers.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkConfigurationHelpers.cs deleted file mode 100644 index 2341f0b0e12..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkConfigurationHelpers.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Net; -using System.Runtime.InteropServices; - -namespace PlatformBenchmarks; - -public static class BenchmarkConfigurationHelpers -{ - public static IWebHostBuilder UseBenchmarksConfiguration(this IWebHostBuilder builder, IConfiguration configuration) - { - builder.UseConfiguration(configuration); - - builder.UseSockets(options => - { - if (int.TryParse(builder.GetSetting("threadCount"), out int threadCount)) - { - options.IOQueueCount = threadCount; - } - - options.WaitForDataBeforeAllocatingBuffer = false; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - options.UnsafePreferInlineScheduling = Environment.GetEnvironmentVariable("DOTNET_SYSTEM_NET_SOCKETS_INLINE_COMPLETIONS") == "1"; - } - - Console.WriteLine($"Options: WaitForData={options.WaitForDataBeforeAllocatingBuffer}, PreferInlineScheduling={options.UnsafePreferInlineScheduling}, IOQueue={options.IOQueueCount}"); - }); - - return builder; - } - - public static IPEndPoint CreateIPEndPoint(this IConfiguration config) - { - var url = config["server.urls"] ?? config["urls"]; - - if (string.IsNullOrEmpty(url)) - { - return new IPEndPoint(IPAddress.Loopback, 8080); - } - - var address = BindingAddress.Parse(url); - - IPAddress ip; - - if (string.Equals(address.Host, "localhost", StringComparison.OrdinalIgnoreCase)) - { - ip = IPAddress.Loopback; - } - else if (!IPAddress.TryParse(address.Host, out ip)) - { - ip = IPAddress.IPv6Any; - } - - return new IPEndPoint(ip, address.Port); - } -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BufferExtensions.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BufferExtensions.cs deleted file mode 100644 index 2fe34f0d0fa..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BufferExtensions.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Buffers; -using System.Runtime.CompilerServices; -using System.Text; - -namespace PlatformBenchmarks; - -// Same as KestrelHttpServer\src\Kestrel.Core\Internal\Http\PipelineExtensions.cs -// However methods accept T : struct, IBufferWriter rather than PipeWriter. -// This allows a struct wrapper to turn CountingBufferWriter into a non-shared generic, -// while still offering the WriteNumeric extension. - -public static class BufferExtensions -{ - private const int _maxULongByteLength = 20; - - [ThreadStatic] - private static byte[] _numericBytesScratch; - - internal static void WriteUtf8String(ref this BufferWriter buffer, string text) - where T : struct, IBufferWriter - { - var byteCount = Encoding.UTF8.GetByteCount(text); - buffer.Ensure(byteCount); - byteCount = Encoding.UTF8.GetBytes(text.AsSpan(), buffer.Span); - buffer.Advance(byteCount); - } - [MethodImpl(MethodImplOptions.NoInlining)] - internal static void WriteNumericMultiWrite(ref this BufferWriter buffer, uint number) - where T : IBufferWriter - { - const byte AsciiDigitStart = (byte)'0'; - - var value = number; - var position = _maxULongByteLength; - var byteBuffer = NumericBytesScratch; - do - { - // Consider using Math.DivRem() if available - var quotient = value / 10; - byteBuffer[--position] = (byte)(AsciiDigitStart + (value - quotient * 10)); // 0x30 = '0' - value = quotient; - } - while (value != 0); - - var length = _maxULongByteLength - position; - buffer.Write(new ReadOnlySpan(byteBuffer, position, length)); - } - - private static byte[] NumericBytesScratch => _numericBytesScratch ?? CreateNumericBytesScratch(); - - [MethodImpl(MethodImplOptions.NoInlining)] - private static byte[] CreateNumericBytesScratch() - { - var bytes = new byte[_maxULongByteLength]; - _numericBytesScratch = bytes; - return bytes; - } -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BufferWriter.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BufferWriter.cs deleted file mode 100644 index 95035307826..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BufferWriter.cs +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Buffers; -using System.Runtime.CompilerServices; - -namespace PlatformBenchmarks; - -public ref struct BufferWriter where T : IBufferWriter -{ - private readonly T _output; - private Span _span; - private int _buffered; - - public BufferWriter(T output, int sizeHint) - { - _buffered = 0; - _output = output; - _span = output.GetSpan(sizeHint); - } - - public Span Span => _span; - - public T Output => _output; - - public int Buffered => _buffered; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Commit() - { - var buffered = _buffered; - if (buffered > 0) - { - _buffered = 0; - _output.Advance(buffered); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Advance(int count) - { - _buffered += count; - _span = _span.Slice(count); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Write(ReadOnlySpan source) - { - if (_span.Length >= source.Length) - { - source.CopyTo(_span); - Advance(source.Length); - } - else - { - WriteMultiBuffer(source); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Ensure(int count = 1) - { - if (_span.Length < count) - { - EnsureMore(count); - } - } - - [MethodImpl(MethodImplOptions.NoInlining)] - private void EnsureMore(int count = 0) - { - if (_buffered > 0) - { - Commit(); - } - - _span = _output.GetSpan(count); - } - - private void WriteMultiBuffer(ReadOnlySpan source) - { - while (source.Length > 0) - { - if (_span.Length == 0) - { - EnsureMore(); - } - - var writable = Math.Min(source.Length, _span.Length); - source[..writable].CopyTo(_span); - source = source[writable..]; - Advance(writable); - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal void WriteNumeric(uint number) - { - const byte AsciiDigitStart = (byte)'0'; - - var span = this.Span; - - // Fast path, try copying to the available memory directly - var advanceBy = 0; - if (span.Length >= 3) - { - if (number < 10) - { - span[0] = (byte)(number + AsciiDigitStart); - advanceBy = 1; - } - else if (number < 100) - { - var tens = (byte)((number * 205u) >> 11); // div10, valid to 1028 - - span[0] = (byte)(tens + AsciiDigitStart); - span[1] = (byte)(number - (tens * 10) + AsciiDigitStart); - advanceBy = 2; - } - else if (number < 1000) - { - var digit0 = (byte)((number * 41u) >> 12); // div100, valid to 1098 - var digits01 = (byte)((number * 205u) >> 11); // div10, valid to 1028 - - span[0] = (byte)(digit0 + AsciiDigitStart); - span[1] = (byte)(digits01 - (digit0 * 10) + AsciiDigitStart); - span[2] = (byte)(number - (digits01 * 10) + AsciiDigitStart); - advanceBy = 3; - } - } - - if (advanceBy > 0) - { - Advance(advanceBy); - } - else - { - BufferExtensions.WriteNumericMultiWrite(ref this, number); - } - } -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Configuration/AppSettings.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Configuration/AppSettings.cs deleted file mode 100644 index 38818920e16..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Configuration/AppSettings.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace PlatformBenchmarks; - -public class AppSettings -{ - public string ConnectionString { get; set; } - - public DatabaseServer Database { get; set; } = DatabaseServer.None; -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Configuration/DatabaseServer.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Configuration/DatabaseServer.cs deleted file mode 100644 index 6d92dfbf82c..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Configuration/DatabaseServer.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace PlatformBenchmarks; - -public enum DatabaseServer -{ - None, - SqlServer, - PostgreSql, - MySql -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/BatchUpdateString.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/BatchUpdateString.cs deleted file mode 100644 index 9eb7ff4edfa..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/BatchUpdateString.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace PlatformBenchmarks; - -internal class BatchUpdateString -{ - private const int MaxBatch = 500; - - public static DatabaseServer DatabaseServer; - - internal static readonly string[] Ids = Enumerable.Range(0, MaxBatch).Select(i => $"@Id_{i}").ToArray(); - internal static readonly string[] Randoms = Enumerable.Range(0, MaxBatch).Select(i => $"@Random_{i}").ToArray(); - - private static readonly string[] _queries = new string[MaxBatch + 1]; - - public static string Query(int batchSize) - { - if (_queries[batchSize] != null) - { - return _queries[batchSize]; - } - - var lastIndex = batchSize - 1; - - var sb = StringBuilderCache.Acquire(); - - if (DatabaseServer == DatabaseServer.PostgreSql) - { - sb.Append("UPDATE world SET randomNumber = temp.randomNumber FROM (VALUES "); - Enumerable.Range(0, lastIndex).ToList().ForEach(i => sb.Append($"(@Id_{i}, @Random_{i}), ")); - sb.Append($"(@Id_{lastIndex}, @Random_{lastIndex}) ORDER BY 1) AS temp(id, randomNumber) WHERE temp.id = world.id"); - } - else - { - Enumerable.Range(0, batchSize).ToList().ForEach(i => sb.Append($"UPDATE world SET randomnumber = @Random_{i} WHERE id = @Id_{i};")); - } - - return _queries[batchSize] = StringBuilderCache.GetStringAndRelease(sb); - } -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/CachedWorld.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/CachedWorld.cs deleted file mode 100644 index 61910b95587..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/CachedWorld.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace PlatformBenchmarks; - -public sealed class CachedWorld -{ - public int Id { get; set; } - - public int RandomNumber { get; set; } - - public static implicit operator CachedWorld(World world) => new CachedWorld { Id = world.Id, RandomNumber = world.RandomNumber }; -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Fortune.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Fortune.cs deleted file mode 100644 index ac39ac82363..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Fortune.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace PlatformBenchmarks; - -public readonly struct Fortune : IComparable, IComparable -{ - public Fortune(int id, string message) - { - Id = id; - Message = message; - } - - public int Id { get; } - - public string Message { get; } - - public int CompareTo(object obj) => throw new InvalidOperationException("The non-generic CompareTo should not be used"); - - // Performance critical, using culture insensitive comparison - public int CompareTo(Fortune other) => string.CompareOrdinal(Message, other.Message); -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/JsonMessage.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/JsonMessage.cs deleted file mode 100644 index 5bfe9115fe2..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/JsonMessage.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace PlatformBenchmarks; - -public struct JsonMessage -{ - public string message { get; set; } -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Providers/RawDbMySqlConnector.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Providers/RawDbMySqlConnector.cs deleted file mode 100644 index 0a0a27559de..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Providers/RawDbMySqlConnector.cs +++ /dev/null @@ -1,272 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if MYSQLCONNECTOR - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Threading.Tasks; -using Microsoft.Extensions.Caching.Memory; -using MySqlConnector; - -namespace PlatformBenchmarks -{ - // Is semantically identical to RawDbNpgsql.cs. - // If you are changing RawDbMySqlConnector.cs, also consider changing RawDbNpgsql.cs. - public class RawDb - { - private readonly ConcurrentRandom _random; - private readonly string _connectionString; - private readonly MemoryCache _cache = new( - new MemoryCacheOptions - { - ExpirationScanFrequency = TimeSpan.FromMinutes(60) - }); - - public RawDb(ConcurrentRandom random, AppSettings appSettings) - { - _random = random; - _connectionString = appSettings.ConnectionString; - } - - public async Task LoadSingleQueryRow() - { - using (var db = new MySqlConnection(_connectionString)) - { - await db.OpenAsync(); - - var (cmd, _) = await CreateReadCommandAsync(db); - using (cmd) - { - return await ReadSingleRow(cmd); - } - } - } - - public async Task LoadMultipleQueriesRows(int count) - { - var result = new World[count]; - - using (var db = new MySqlConnection(_connectionString)) - { - await db.OpenAsync(); - - var (cmd, idParameter) = await CreateReadCommandAsync(db); - using (cmd) - { - for (int i = 0; i < result.Length; i++) - { - result[i] = await ReadSingleRow(cmd); - idParameter.Value = _random.Next(1, 10001); - } - } - } - - return result; - } - - public Task LoadCachedQueries(int count) - { - var result = new CachedWorld[count]; - var cacheKeys = _cacheKeys; - var cache = _cache; - var random = _random; - for (var i = 0; i < result.Length; i++) - { - var id = random.Next(1, 10001); - var key = cacheKeys[id]; - if (cache.TryGetValue(key, out object cached)) - { - result[i] = (CachedWorld)cached; - } - else - { - return LoadUncachedQueries(id, i, count, this, result); - } - } - - return Task.FromResult(result); - - static async Task LoadUncachedQueries(int id, int i, int count, RawDb rawdb, CachedWorld[] result) - { - using (var db = new MySqlConnection(rawdb._connectionString)) - { - await db.OpenAsync(); - - var (cmd, idParameter) = await rawdb.CreateReadCommandAsync(db); - using (cmd) - { - Func> create = async _ => - { - return await rawdb.ReadSingleRow(cmd); - }; - - var cacheKeys = _cacheKeys; - var key = cacheKeys[id]; - - idParameter.Value = id; - - for (; i < result.Length; i++) - { - result[i] = await rawdb._cache.GetOrCreateAsync(key, create); - - id = rawdb._random.Next(1, 10001); - idParameter.Value = id; - key = cacheKeys[id]; - } - } - } - - return result; - } - } - - public async Task PopulateCache() - { - using (var db = new MySqlConnection(_connectionString)) - { - await db.OpenAsync(); - - var (cmd, idParameter) = await CreateReadCommandAsync(db); - using (cmd) - { - var cacheKeys = _cacheKeys; - var cache = _cache; - for (var i = 1; i < 10001; i++) - { - idParameter.Value = i; - cache.Set(cacheKeys[i], await ReadSingleRow(cmd)); - } - } - } - - Console.WriteLine("Caching Populated"); - } - - public async Task LoadMultipleUpdatesRows(int count) - { - var results = new World[count]; - - using (var db = new MySqlConnection(_connectionString)) - { - await db.OpenAsync(); - - var (queryCmd, queryParameter) = await CreateReadCommandAsync(db); - using (queryCmd) - { - for (int i = 0; i < results.Length; i++) - { - results[i] = await ReadSingleRow(queryCmd); - queryParameter.Value = _random.Next(1, 10001); - } - } - - using (var updateCmd = new MySqlCommand(BatchUpdateString.Query(count), db)) - { - var ids = BatchUpdateString.Ids; - var randoms = BatchUpdateString.Randoms; - - for (int i = 0; i < results.Length; i++) - { - var randomNumber = _random.Next(1, 10001); - - updateCmd.Parameters.Add(new MySqlParameter(ids[i], results[i].Id)); - updateCmd.Parameters.Add(new MySqlParameter(randoms[i], randomNumber)); - - results[i].RandomNumber = randomNumber; - } - - await updateCmd.ExecuteNonQueryAsync(); - } - } - - return results; - } - - public async Task> LoadFortunesRows() - { - var result = new List(); - - using (var db = new MySqlConnection(_connectionString)) - { - await db.OpenAsync(); - - using (var cmd = new MySqlCommand("SELECT id, message FROM fortune", db)) - { - await cmd.PrepareAsync(); - - using (var rdr = await cmd.ExecuteReaderAsync()) - { - while (await rdr.ReadAsync()) - { - result.Add( - new Fortune - ( - id: rdr.GetInt32(0), - message: rdr.GetString(1) - )); - } - } - } - } - - result.Add(new Fortune(id: 0, message: "Additional fortune added at request time." )); - result.Sort(); - - return result; - } - - private async Task<(MySqlCommand readCmd, MySqlParameter idParameter)> CreateReadCommandAsync(MySqlConnection connection) - { - var cmd = new MySqlCommand("SELECT id, randomnumber FROM world WHERE id = @Id", connection); - var parameter = new MySqlParameter("@Id", _random.Next(1, 10001)); - - cmd.Parameters.Add(parameter); - - await cmd.PrepareAsync(); - - return (cmd, parameter); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async Task ReadSingleRow(MySqlCommand cmd) - { - using (var rdr = await cmd.ExecuteReaderAsync(System.Data.CommandBehavior.SingleRow)) - { - await rdr.ReadAsync(); - - return new World - { - Id = rdr.GetInt32(0), - RandomNumber = rdr.GetInt32(1) - }; - } - } - - private static readonly object[] _cacheKeys = Enumerable.Range(0, 10001).Select(i => new CacheKey(i)).ToArray(); - - public sealed class CacheKey : IEquatable - { - private readonly int _value; - - public CacheKey(int value) - => _value = value; - - public bool Equals(CacheKey key) - => key._value == _value; - - public override bool Equals(object obj) - => ReferenceEquals(obj, this); - - public override int GetHashCode() - => _value; - - public override string ToString() - => _value.ToString(); - } - } -} - -#endif \ No newline at end of file diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Providers/RawDbNpgsql.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Providers/RawDbNpgsql.cs deleted file mode 100644 index 96391492ba8..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Providers/RawDbNpgsql.cs +++ /dev/null @@ -1,265 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if NPGSQL - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Threading.Tasks; -using Microsoft.Extensions.Caching.Memory; -using Npgsql; - -namespace PlatformBenchmarks -{ - // Is semantically identical to RawDbMySqlConnector.cs. - // If you are changing RawDbNpgsql.cs, also consider changing RawDbMySqlConnector.cs. - public class RawDb - { - private readonly ConcurrentRandom _random; - private readonly string _connectionString; - private readonly MemoryCache _cache = new( - new MemoryCacheOptions - { - ExpirationScanFrequency = TimeSpan.FromMinutes(60) - }); - - public RawDb(ConcurrentRandom random, AppSettings appSettings) - { - _random = random; - _connectionString = appSettings.ConnectionString; - } - - public async Task LoadSingleQueryRow() - { - using (var db = new NpgsqlConnection(_connectionString)) - { - await db.OpenAsync(); - - var (cmd, _) = CreateReadCommand(db); - using (cmd) - { - return await ReadSingleRow(cmd); - } - } - } - - public async Task LoadMultipleQueriesRows(int count) - { - var result = new World[count]; - - using (var db = new NpgsqlConnection(_connectionString)) - { - await db.OpenAsync(); - - var (cmd, idParameter) = CreateReadCommand(db); - using (cmd) - { - for (int i = 0; i < result.Length; i++) - { - result[i] = await ReadSingleRow(cmd); - idParameter.TypedValue = _random.Next(1, 10001); - } - } - } - - return result; - } - - public Task LoadCachedQueries(int count) - { - var result = new CachedWorld[count]; - var cacheKeys = _cacheKeys; - var cache = _cache; - var random = _random; - for (var i = 0; i < result.Length; i++) - { - var id = random.Next(1, 10001); - var key = cacheKeys[id]; - if (cache.TryGetValue(key, out object cached)) - { - result[i] = (CachedWorld)cached; - } - else - { - return LoadUncachedQueries(id, i, count, this, result); - } - } - - return Task.FromResult(result); - - static async Task LoadUncachedQueries(int id, int i, int count, RawDb rawdb, CachedWorld[] result) - { - using (var db = new NpgsqlConnection(rawdb._connectionString)) - { - await db.OpenAsync(); - - var (cmd, idParameter) = rawdb.CreateReadCommand(db); - using (cmd) - { - Func> create = async _ => - { - return await rawdb.ReadSingleRow(cmd); - }; - - var cacheKeys = _cacheKeys; - var key = cacheKeys[id]; - - idParameter.TypedValue = id; - - for (; i < result.Length; i++) - { - result[i] = await rawdb._cache.GetOrCreateAsync(key, create); - - id = rawdb._random.Next(1, 10001); - idParameter.TypedValue = id; - key = cacheKeys[id]; - } - } - } - - return result; - } - } - - public async Task PopulateCache() - { - using (var db = new NpgsqlConnection(_connectionString)) - { - await db.OpenAsync(); - - var (cmd, idParameter) = CreateReadCommand(db); - using (cmd) - { - var cacheKeys = _cacheKeys; - var cache = _cache; - for (var i = 1; i < 10001; i++) - { - idParameter.TypedValue = i; - cache.Set(cacheKeys[i], await ReadSingleRow(cmd)); - } - } - } - - Console.WriteLine("Caching Populated"); - } - - public async Task LoadMultipleUpdatesRows(int count) - { - var results = new World[count]; - - using (var db = new NpgsqlConnection(_connectionString)) - { - await db.OpenAsync(); - - var (queryCmd, queryParameter) = CreateReadCommand(db); - using (queryCmd) - { - for (int i = 0; i < results.Length; i++) - { - results[i] = await ReadSingleRow(queryCmd); - queryParameter.TypedValue = _random.Next(1, 10001); - } - } - - using (var updateCmd = new NpgsqlCommand(BatchUpdateString.Query(count), db)) - { - var ids = BatchUpdateString.Ids; - var randoms = BatchUpdateString.Randoms; - - for (int i = 0; i < results.Length; i++) - { - var randomNumber = _random.Next(1, 10001); - - updateCmd.Parameters.Add(new NpgsqlParameter(parameterName: ids[i], value: results[i].Id)); - updateCmd.Parameters.Add(new NpgsqlParameter(parameterName: randoms[i], value: randomNumber)); - - results[i].RandomNumber = randomNumber; - } - - await updateCmd.ExecuteNonQueryAsync(); - } - } - - return results; - } - - public async Task> LoadFortunesRows() - { - var result = new List(20); - - using (var db = new NpgsqlConnection(_connectionString)) - { - await db.OpenAsync(); - - using (var cmd = new NpgsqlCommand("SELECT id, message FROM fortune", db)) - using (var rdr = await cmd.ExecuteReaderAsync()) - { - while (await rdr.ReadAsync()) - { - result.Add(new Fortune - ( - id:rdr.GetInt32(0), - message: rdr.GetString(1) - )); - } - } - } - - result.Add(new Fortune(id: 0, message: "Additional fortune added at request time." )); - result.Sort(); - - return result; - } - - private (NpgsqlCommand readCmd, NpgsqlParameter idParameter) CreateReadCommand(NpgsqlConnection connection) - { - var cmd = new NpgsqlCommand("SELECT id, randomnumber FROM world WHERE id = $1", connection); - var parameter = new NpgsqlParameter { TypedValue = _random.Next(1, 10001) }; - - cmd.Parameters.Add(parameter); - - return (cmd, parameter); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private async Task ReadSingleRow(NpgsqlCommand cmd) - { - using (var rdr = await cmd.ExecuteReaderAsync(System.Data.CommandBehavior.SingleRow)) - { - await rdr.ReadAsync(); - - return new World - { - Id = rdr.GetInt32(0), - RandomNumber = rdr.GetInt32(1) - }; - } - } - - private static readonly object[] _cacheKeys = Enumerable.Range(0, 10001).Select(i => new CacheKey(i)).ToArray(); - - public sealed class CacheKey : IEquatable - { - private readonly int _value; - - public CacheKey(int value) - => _value = value; - - public bool Equals(CacheKey key) - => key._value == _value; - - public override bool Equals(object obj) - => ReferenceEquals(obj, this); - - public override int GetHashCode() - => _value; - - public override string ToString() - => _value.ToString(); - } - } -} - -#endif \ No newline at end of file diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Random.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Random.cs deleted file mode 100644 index c5c634a2723..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Random.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Runtime.CompilerServices; - -namespace PlatformBenchmarks; - -public class ConcurrentRandom -{ - private static int nextSeed = 0; - - // Random isn't thread safe - [ThreadStatic] - private static Random _random; - - private static Random Random => _random ?? CreateRandom(); - - [MethodImpl(MethodImplOptions.NoInlining)] - private static Random CreateRandom() - { - _random = new Random(Interlocked.Increment(ref nextSeed)); - return _random; - } - - public int Next(int minValue, int maxValue) - { - return Random.Next(minValue, maxValue); - } -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/World.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/World.cs deleted file mode 100644 index 89ba3ea87bf..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/World.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Runtime.InteropServices; - -namespace PlatformBenchmarks; - -[StructLayout(LayoutKind.Sequential, Size = 8)] -public struct World -{ - public int Id { get; set; } - - public int RandomNumber { get; set; } -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/DateHeader.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/DateHeader.cs deleted file mode 100644 index 9e768ad1f53..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/DateHeader.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Buffers.Text; -using System.Diagnostics; -using System.Text; - -namespace PlatformBenchmarks; - -/// -/// Manages the generation of the date header value. -/// -internal static class DateHeader -{ - const int prefixLength = 8; // "\r\nDate: ".Length - const int dateTimeRLength = 29; // Wed, 14 Mar 2018 14:20:00 GMT - const int suffixLength = 2; // crlf - const int suffixIndex = dateTimeRLength + prefixLength; - - private static readonly Timer s_timer = new((s) => - { - SetDateValues(DateTimeOffset.UtcNow); - }, null, 1000, 1000); - - private static byte[] s_headerBytesMaster = new byte[prefixLength + dateTimeRLength + 2 * suffixLength]; - private static byte[] s_headerBytesScratch = new byte[prefixLength + dateTimeRLength + 2 * suffixLength]; - - static DateHeader() - { - var utf8 = Encoding.ASCII.GetBytes("\r\nDate: ").AsSpan(); - - utf8.CopyTo(s_headerBytesMaster); - utf8.CopyTo(s_headerBytesScratch); - s_headerBytesMaster[suffixIndex] = (byte)'\r'; - s_headerBytesMaster[suffixIndex + 1] = (byte)'\n'; - s_headerBytesMaster[suffixIndex + 2] = (byte)'\r'; - s_headerBytesMaster[suffixIndex + 3] = (byte)'\n'; - s_headerBytesScratch[suffixIndex] = (byte)'\r'; - s_headerBytesScratch[suffixIndex + 1] = (byte)'\n'; - s_headerBytesScratch[suffixIndex + 2] = (byte)'\r'; - s_headerBytesScratch[suffixIndex + 3] = (byte)'\n'; - - SetDateValues(DateTimeOffset.UtcNow); - SyncDateTimer(); - } - - public static void SyncDateTimer() => s_timer.Change(1000, 1000); - - public static ReadOnlySpan HeaderBytes => s_headerBytesMaster; - - private static void SetDateValues(DateTimeOffset value) - { - lock (s_headerBytesScratch) - { - if (!Utf8Formatter.TryFormat(value, s_headerBytesScratch.AsSpan(prefixLength), out var written, 'R')) - { - throw new Exception("date time format failed"); - } - Debug.Assert(written == dateTimeRLength); - var temp = s_headerBytesMaster; - s_headerBytesMaster = s_headerBytesScratch; - s_headerBytesScratch = temp; - } - } -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/HttpApplication.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/HttpApplication.cs deleted file mode 100644 index bed4e9de36a..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/HttpApplication.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Threading.Tasks; -using Microsoft.AspNetCore.Connections; - -namespace PlatformBenchmarks; - -public static class HttpApplicationConnectionBuilderExtensions -{ - public static IConnectionBuilder UseHttpApplication(this IConnectionBuilder builder) where TConnection : IHttpConnection, new() - { - return builder.Use(next => new HttpApplication().ExecuteAsync); - } -} - -public class HttpApplication where TConnection : IHttpConnection, new() -{ - public Task ExecuteAsync(ConnectionContext connection) - { - var httpConnection = new TConnection - { - Reader = connection.Transport.Input, - Writer = connection.Transport.Output - }; - return httpConnection.ExecuteAsync(); - } -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/IHttpConnection.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/IHttpConnection.cs deleted file mode 100644 index d2dee82255b..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/IHttpConnection.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.IO.Pipelines; -using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; - -namespace PlatformBenchmarks; - -public interface IHttpConnection : IHttpHeadersHandler, IHttpRequestLineHandler -{ - PipeReader Reader { get; set; } - PipeWriter Writer { get; set; } - Task ExecuteAsync(); -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/NuGet.Config b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/NuGet.Config deleted file mode 100644 index 06f3398dd3b..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/NuGet.Config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/PlatformBenchmarks.csproj b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/PlatformBenchmarks.csproj deleted file mode 100644 index 6116f434cda..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/PlatformBenchmarks.csproj +++ /dev/null @@ -1,40 +0,0 @@ - - - net6.0 - Exe - true - - - link - Speed - true - true - - - true - false - false - false - enable - - - - $(DefineConstants);DATABASE - $(DefineConstants);NPGSQL - $(DefineConstants);MYSQLCONNECTOR - - - - - - - - - - - - - - - - diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Program.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Program.cs deleted file mode 100644 index d684abb40e8..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Program.cs +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Runtime.InteropServices; - -namespace PlatformBenchmarks; - -public class Program -{ - public static string[] Args; - - public static async Task Main(string[] args) - { - Args = args; - - Console.WriteLine(BenchmarkApplication.ApplicationName); -#if !DATABASE - Console.WriteLine(BenchmarkApplication.Paths.Plaintext); - Console.WriteLine(BenchmarkApplication.Paths.Json); -#else - Console.WriteLine(BenchmarkApplication.Paths.Fortunes); - Console.WriteLine(BenchmarkApplication.Paths.SingleQuery); - Console.WriteLine(BenchmarkApplication.Paths.Updates); - Console.WriteLine(BenchmarkApplication.Paths.MultipleQueries); -#endif - DateHeader.SyncDateTimer(); - - var host = BuildWebHost(args); - var config = (IConfiguration)host.Services.GetService(typeof(IConfiguration)); - BatchUpdateString.DatabaseServer = config.Get().Database; -#if DATABASE - await BenchmarkApplication.Db.PopulateCache(); -#endif - await host.RunAsync(); - } - - public static IWebHost BuildWebHost(string[] args) - { - var config = new ConfigurationBuilder() - .AddJsonFile("appsettings.json") - .AddEnvironmentVariables() - .AddEnvironmentVariables(prefix: "ASPNETCORE_") - .AddCommandLine(args) - .Build(); - - var appSettings = config.Get(); -#if DATABASE - Console.WriteLine($"Database: {appSettings.Database}"); - Console.WriteLine($"ConnectionString: {appSettings.ConnectionString}"); - - if (appSettings.Database is DatabaseServer.PostgreSql - or DatabaseServer.MySql) - { - BenchmarkApplication.Db = new RawDb(new ConcurrentRandom(), appSettings); - } - else - { - throw new NotSupportedException($"{appSettings.Database} is not supported"); - } -#endif - - var hostBuilder = new WebHostBuilder() - .UseBenchmarksConfiguration(config) - .UseKestrel((context, options) => - { - var endPoint = context.Configuration.CreateIPEndPoint(); - - options.Listen(endPoint, builder => - { - builder.UseHttpApplication(); - }); - }) - .UseStartup(); - - hostBuilder.UseSockets(options => - { - options.WaitForDataBeforeAllocatingBuffer = false; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - options.UnsafePreferInlineScheduling = Environment.GetEnvironmentVariable("DOTNET_SYSTEM_NET_SOCKETS_INLINE_COMPLETIONS") == "1"; - } - }); - - - var host = hostBuilder.Build(); - - return host; - } -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Startup.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Startup.cs deleted file mode 100644 index 640f7a3d86d..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Startup.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace PlatformBenchmarks; - -public class Startup -{ - public void Configure(IApplicationBuilder app) - { - } -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/StringBuilderCache.cs b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/StringBuilderCache.cs deleted file mode 100644 index d1d6c69d354..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/StringBuilderCache.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Text; - -namespace PlatformBenchmarks; - -internal static class StringBuilderCache -{ - private const int DefaultCapacity = 1386; - private const int MaxBuilderSize = DefaultCapacity * 3; - - [ThreadStatic] - private static StringBuilder t_cachedInstance; - - /// Get a StringBuilder for the specified capacity. - /// If a StringBuilder of an appropriate size is cached, it will be returned and the cache emptied. - public static StringBuilder Acquire(int capacity = DefaultCapacity) - { - if (capacity <= MaxBuilderSize) - { - StringBuilder sb = t_cachedInstance; - if (capacity < DefaultCapacity) - { - capacity = DefaultCapacity; - } - - if (sb != null) - { - // Avoid stringbuilder block fragmentation by getting a new StringBuilder - // when the requested size is larger than the current capacity - if (capacity <= sb.Capacity) - { - t_cachedInstance = null; - sb.Clear(); - return sb; - } - } - } - return new StringBuilder(capacity); - } - - public static void Release(StringBuilder sb) - { - if (sb.Capacity <= MaxBuilderSize) - { - t_cachedInstance = sb; - } - } - - public static string GetStringAndRelease(StringBuilder sb) - { - string result = sb.ToString(); - Release(sb); - return result; - } -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.json b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.json deleted file mode 100644 index d7a356382f6..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=aspnetcore-Benchmarks;Trusted_Connection=True;MultipleActiveResultSets=true" -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.mysql.json b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.mysql.json deleted file mode 100644 index 5db959976d2..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.mysql.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "ConnectionString": "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=1024;SslMode=None;ConnectionReset=false;ConnectionIdlePingTime=900;ConnectionIdleTimeout=0;AutoEnlist=false;DefaultCommandTimeout=0;ConnectionTimeout=0;IgnorePrepare=false;", - "Database": "mysql" -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.postgresql.json b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.postgresql.json deleted file mode 100644 index 48ba2b683ff..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.postgresql.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "ConnectionString": "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;SSL Mode=Disable;Maximum Pool Size=18;Enlist=false;Max Auto Prepare=4;Multiplexing=true;Write Coalescing Buffer Threshold Bytes=1000", - "Database": "postgresql" -} diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.postgresql.updates.json b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.postgresql.updates.json deleted file mode 100644 index 83e94d7c745..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.postgresql.updates.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "ConnectionString": "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;SSL Mode=Disable;Maximum Pool Size=18;Enlist=false;Max Auto Prepare=4;Multiplexing=true;Write Coalescing Buffer Threshold Bytes=1000", - "Database": "postgresql" -} diff --git a/frameworks/CSharp/aspnetcore-corert/README.md b/frameworks/CSharp/aspnetcore-corert/README.md deleted file mode 100644 index af5472f8e99..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# ASP.NET Core Tests on Windows and Linux - -See [.NET CoreRT](https://github.com/dotnet/corert) and [ASP.NET Core](https://github.com/aspnet) for more information. - -This includes tests for plaintext and json serialization. - -## Infrastructure Software Versions - -**Language** - -* C# 7.0 - -**Platforms** - -* .NET [CoreRT](https://github.com/dotnet/corert), a .NET Core runtime optimized for AOT (ahead of time compilation), with the accompanying .NET native compiler toolchain - -**Web Servers** - -* [Kestrel](https://github.com/aspnet/KestrelHttpServer) - -**Web Stack** - -* ASP.NET Core - -## Paths & Source for Tests - -* [Plaintext](PlatformBenchmarks/BenchmarkApplication.Plaintext.cs): "/plaintext" -* [JSON Serialization](PlatformBenchmarks/BenchmarkApplication.Json.cs): "/json" diff --git a/frameworks/CSharp/aspnetcore-corert/aspcore-corert-ado-pg-up.dockerfile b/frameworks/CSharp/aspnetcore-corert/aspcore-corert-ado-pg-up.dockerfile deleted file mode 100644 index 12143409aa0..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/aspcore-corert-ado-pg-up.dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build -RUN apt-get update -RUN apt-get -yqq install clang zlib1g-dev libkrb5-dev -WORKDIR /app -COPY PlatformBenchmarks . -RUN dotnet publish -c Release -o out /p:DatabaseProvider=Npgsql -r linux-x64 - -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime -ENV ASPNETCORE_URLS http://+:8080 - -WORKDIR /app -COPY --from=build /app/out ./ -COPY PlatformBenchmarks/appsettings.postgresql.updates.json ./appsettings.json - -EXPOSE 8080 - -ENTRYPOINT ["./PlatformBenchmarks"] diff --git a/frameworks/CSharp/aspnetcore-corert/aspcore-corert-ado-pg.dockerfile b/frameworks/CSharp/aspnetcore-corert/aspcore-corert-ado-pg.dockerfile deleted file mode 100644 index 9ae3632f690..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/aspcore-corert-ado-pg.dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build -RUN apt-get update -RUN apt-get -yqq install clang zlib1g-dev libkrb5-dev -WORKDIR /app -COPY PlatformBenchmarks . -RUN dotnet publish -c Release -o out /p:DatabaseProvider=Npgsql -r linux-x64 - -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime -ENV ASPNETCORE_URLS http://+:8080 - -WORKDIR /app -COPY --from=build /app/out ./ -COPY PlatformBenchmarks/appsettings.postgresql.json ./appsettings.json - -EXPOSE 8080 - -ENTRYPOINT ["./PlatformBenchmarks"] diff --git a/frameworks/CSharp/aspnetcore-corert/aspcore-corert.dockerfile b/frameworks/CSharp/aspnetcore-corert/aspcore-corert.dockerfile deleted file mode 100644 index d813fdcb73a..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/aspcore-corert.dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build -RUN apt-get update -RUN apt-get -yqq install clang zlib1g-dev libkrb5-dev -WORKDIR /app -COPY PlatformBenchmarks . -RUN dotnet publish -c Release -o out -r linux-x64 - -FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime -ENV ASPNETCORE_URLS http://+:8080 -ENV DOTNET_SYSTEM_NET_SOCKETS_INLINE_COMPLETIONS 1 -WORKDIR /app -COPY --from=build /app/out ./ - -EXPOSE 8080 - -ENTRYPOINT ["./PlatformBenchmarks"] diff --git a/frameworks/CSharp/aspnetcore-corert/benchmark_config.json b/frameworks/CSharp/aspnetcore-corert/benchmark_config.json deleted file mode 100644 index 742eab77aa6..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/benchmark_config.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "framework": "aspcore-corert", - "tests": [{ - "default": { - "plaintext_url": "/plaintext", - "json_url": "/json", - "port": 8080, - "approach": "Stripped", - "classification": "Platform", - "database": "None", - "framework": "ASP.NET Core", - "language": "C#", - "orm": "Raw", - "platform": ".NET", - "flavor": "CoreRT", - "webserver": "Kestrel", - "os": "Linux", - "database_os": "Linux", - "display_name": "ASP.NET Core [Platform, CoreRT]", - "notes": "", - "versus": "aspcore" - }, - "ado-pg": { - "fortune_url": "/fortunes", - "db_url": "/db", - "query_url": "/queries/", - "cached_query_url": "/cached-worlds/", - "port": 8080, - "approach": "Stripped", - "classification": "Platform", - "database": "Postgres", - "framework": "ASP.NET Core", - "language": "C#", - "orm": "Raw", - "platform": ".NET", - "flavor": "CoreRT", - "webserver": "Kestrel", - "os": "Linux", - "database_os": "Linux", - "display_name": "ASP.NET Core [Platform, CoreRT, Pg]", - "notes": "", - "versus": "aspcore-ado-pg" - }, - "ado-pg-up": { - "update_url": "/updates/", - "port": 8080, - "approach": "Stripped", - "classification": "Platform", - "database": "Postgres", - "framework": "ASP.NET Core", - "language": "C#", - "orm": "Raw", - "platform": ".NET", - "flavor": "CoreRT", - "webserver": "Kestrel", - "os": "Linux", - "database_os": "Linux", - "display_name": "ASP.NET Core [Platform, CoreRT, Pg]", - "notes": "", - "versus": "aspcore-ado-pg-up" - } - }] -} diff --git a/frameworks/CSharp/aspnetcore-corert/config.toml b/frameworks/CSharp/aspnetcore-corert/config.toml deleted file mode 100644 index adc25e3d358..00000000000 --- a/frameworks/CSharp/aspnetcore-corert/config.toml +++ /dev/null @@ -1,42 +0,0 @@ -[framework] -name = "aspnetcore-corert" - -[ado-pg] -urls.db = "/db" -urls.query = "/queries/" -urls.fortune = "/fortunes" -urls.cached_query = "/cached-worlds/" -approach = "Stripped" -classification = "Platform" -database = "Postgres" -database_os = "Linux" -os = "Linux" -orm = "Raw" -platform = ".NET" -webserver = "Kestrel" -versus = "aspcore-ado-pg" - -[main] -urls.plaintext = "/plaintext" -urls.json = "/json" -approach = "Stripped" -classification = "Platform" -database = "None" -database_os = "Linux" -os = "Linux" -orm = "Raw" -platform = ".NET" -webserver = "Kestrel" -versus = "aspcore" - -[ado-pg-up] -urls.update = "/updates/" -approach = "Stripped" -classification = "Platform" -database = "Postgres" -database_os = "Linux" -os = "Linux" -orm = "Raw" -platform = ".NET" -webserver = "Kestrel" -versus = "aspcore-ado-pg-up" From 0df35bfc877667b186544331b88529615c6ec096 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Mon, 21 Nov 2022 15:31:21 +0000 Subject: [PATCH 7/7] Apply suggestions from code review Co-authored-by: Damian Edwards --- frameworks/CSharp/aspnetcore/benchmark_config.json | 4 ++-- frameworks/CSharp/aspnetcore/config.toml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frameworks/CSharp/aspnetcore/benchmark_config.json b/frameworks/CSharp/aspnetcore/benchmark_config.json index 0487405dc30..679f9e5393d 100644 --- a/frameworks/CSharp/aspnetcore/benchmark_config.json +++ b/frameworks/CSharp/aspnetcore/benchmark_config.json @@ -24,7 +24,7 @@ "plaintext_url": "/plaintext", "json_url": "/json", "port": 8080, - "approach": "Realistic", + "approach": "Stripped", "classification": "Platform", "database": "None", "framework": "ASP.NET Core", @@ -102,7 +102,7 @@ "aot-ado-pg-up": { "update_url": "/updates/", "port": 8080, - "approach": "Realistic", + "approach": "Stripped", "classification": "Platform", "database": "Postgres", "framework": "ASP.NET Core", diff --git a/frameworks/CSharp/aspnetcore/config.toml b/frameworks/CSharp/aspnetcore/config.toml index 42cb9e5d20a..6ef8343626f 100644 --- a/frameworks/CSharp/aspnetcore/config.toml +++ b/frameworks/CSharp/aspnetcore/config.toml @@ -21,7 +21,7 @@ urls.db = "/db" urls.query = "/queries/" urls.fortune = "/fortunes" urls.cached_query = "/cached-worlds/" -approach = "Realistic" +approach = "Stripped" classification = "Platform" database = "Postgres" database_os = "Linux" @@ -280,7 +280,7 @@ versus = "aspcore" [aot] urls.plaintext = "/plaintext" urls.json = "/json" -approach = "Realistic" +approach = "Stripped" classification = "Platform" database = "None" database_os = "Linux" @@ -340,7 +340,7 @@ versus = "aspcore-ado-pg-up" [aot-ado-pg-up] urls.update = "/updates/" -approach = "Realistic" +approach = "Stripped" classification = "Platform" database = "Postgres" database_os = "Linux"