Browse Source

Upgrading to dotnet core 3.0 preview7 (#5008)

* Upgrading to dotnet core 3.0 preview7

Corresponds to the changes made in #4955.

* Fix Linux

* Do not use SDK 3.0 image for build

Hit trouble because the CoreRT compiler targets netcoreapp2.1 and we don't have the right dependencies (and I can't figure out the way to install libssl1.0 in the .NET Core 3.0 container). Working around by just installing the 3.0 SDK into the 2.2 container.
Michal Strehovský 6 years ago
parent
commit
07764a3762

+ 1 - 2
frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/AsciiString.cs

@@ -3,7 +3,6 @@
 
 using System;
 using System.Text;
-using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
 
 namespace PlatformBenchmarks
 {
@@ -22,7 +21,7 @@ namespace PlatformBenchmarks
 
         public static implicit operator AsciiString(string str) => new AsciiString(str);
 
-        public override string ToString() => HttpUtilities.GetAsciiStringNonNullCharacters(_data);
+        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);

+ 24 - 9
frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.HttpConnection.cs

@@ -41,6 +41,13 @@ namespace PlatformBenchmarks
             }
         }
 
+        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);
+        }
+
         private async Task ProcessRequestsAsync()
         {
             while (true)
@@ -103,10 +110,19 @@ namespace PlatformBenchmarks
 
                 if (state == State.Headers)
                 {
-                    if (Parser.ParseHeaders(new ParsingAdapter(this), buffer, out consumed, out examined, out int consumedBytes))
+                    var reader = new SequenceReader<byte>(buffer);
+                    var success = Parser.ParseHeaders(new ParsingAdapter(this), ref reader);
+
+                    consumed = reader.Position;
+                    if (success)
                     {
+                        examined = consumed;
                         state = State.Body;
                     }
+                    else
+                    {
+                        examined = buffer.End;
+                    }
 
                     buffer = buffer.Slice(consumed);
                 }
@@ -129,16 +145,13 @@ namespace PlatformBenchmarks
         {
         }
 
-        public async ValueTask OnReadCompletedAsync()
+        public void OnHeadersComplete()
         {
-            await Writer.FlushAsync();
         }
 
-        private static HtmlEncoder CreateHtmlEncoder()
+        public async ValueTask OnReadCompletedAsync()
         {
-            var settings = new TextEncoderSettings(UnicodeRanges.BasicLatin, UnicodeRanges.Katakana, UnicodeRanges.Hiragana);
-            settings.AllowCharacter('\u2014');  // allow EM DASH through
-            return HtmlEncoder.Create(settings);
+            await Writer.FlushAsync();
         }
 
         private static void ThrowUnexpectedEndOfData()
@@ -186,7 +199,9 @@ namespace PlatformBenchmarks
 
             public void OnStartLine(HttpMethod method, HttpVersion version, Span<byte> target, Span<byte> path, Span<byte> query, Span<byte> customMethod, bool pathEncoded)
                 => RequestHandler.OnStartLine(method, version, target, path, query, customMethod, pathEncoded);
+
+            public void OnHeadersComplete()
+                => RequestHandler.OnHeadersComplete();
         }
     }
-
-}
+}

+ 23 - 16
frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkConfigurationHelpers.cs

@@ -3,12 +3,9 @@
 
 using System;
 using System.Net;
-using Microsoft.AspNetCore;
 using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Server.Kestrel.Core;
-using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
+using Microsoft.AspNetCore.Http;
 using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
 
 namespace PlatformBenchmarks
 {
@@ -31,24 +28,34 @@ namespace PlatformBenchmarks
                 theadCount = value;
             }
 
-            if (string.Equals(webHost, "LinuxTransport", StringComparison.OrdinalIgnoreCase))
+            if (string.Equals(webHost, "Sockets", StringComparison.OrdinalIgnoreCase))
             {
-                builder.ConfigureServices(services =>
-                {
-                    services.Configure<KestrelServerOptions>(options =>
-                    {
-                        // Run callbacks on the transport thread
-                        options.ApplicationSchedulingMode = SchedulingMode.Inline;
-                    });
-                })
-                .UseLinuxTransport(options =>
+                builder.UseSockets(options =>
                 {
                     if (theadCount.HasValue)
                     {
-                        options.ThreadCount = theadCount.Value;
+                        options.IOQueueCount = theadCount.Value;
                     }
                 });
             }
+            // else if (string.Equals(webHost, "LinuxTransport", StringComparison.OrdinalIgnoreCase))
+            // {
+            //     builder.ConfigureServices(services =>
+            //     {
+            //         services.Configure<KestrelServerOptions>(options =>
+            //         {
+            //             // Run callbacks on the transport thread
+            //             options.ApplicationSchedulingMode = SchedulingMode.Inline;
+            //         });
+            //     })
+            //     .UseLinuxTransport(options =>
+            //     {
+            //         if (theadCount.HasValue)
+            //         {
+            //             options.ThreadCount = theadCount.Value;
+            //         }
+            //     });
+            // }
 
             return builder;
         }
@@ -62,7 +69,7 @@ namespace PlatformBenchmarks
                 return new IPEndPoint(IPAddress.Loopback, 8080);
             }
 
-            var address = ServerAddress.FromUrl(url);
+            var address = BindingAddress.Parse(url);
 
             IPAddress ip;
 

+ 1 - 1
frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Utilities/BufferExtensions.cs → frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BufferExtensions.cs

@@ -42,7 +42,7 @@ namespace PlatformBenchmarks
 
             // Fast path, try copying to the available memory directly
             var advanceBy = 0;
-            fixed (byte* output = &MemoryMarshal.GetReference(span))
+            fixed (byte* output = span)
             {
                 var start = output;
                 if (number < 10 && bytesLeftInBlock >= 1)

+ 1 - 0
frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Utilities/BufferWriter.cs → frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BufferWriter.cs

@@ -21,6 +21,7 @@ namespace PlatformBenchmarks
         }
 
         public Span<byte> Span => _span;
+
         public int Buffered => _buffered;
 
         [MethodImpl(MethodImplOptions.AggressiveInlining)]

+ 4 - 5
frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Utilities/DateHeader.cs → frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/DateHeader.cs

@@ -1,4 +1,4 @@
-// Copyright (c) .NET Foundation. All rights reserved.
+// 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;
@@ -6,14 +6,13 @@ using System.Buffers.Text;
 using System.Diagnostics;
 using System.Text;
 using System.Threading;
-using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
 
-namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
+namespace PlatformBenchmarks
 {
     /// <summary>
     /// Manages the generation of the date header value.
     /// </summary>
-    internal static class DateHeader 
+    internal static class DateHeader
     {
         const int prefixLength = 8; // "\r\nDate: ".Length
         const int dateTimeRLength = 29; // Wed, 14 Mar 2018 14:20:00 GMT
@@ -59,4 +58,4 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
             }
         }
     }
-}
+}

+ 5 - 3
frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/PlatformBenchmarks.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk.Web">
 
   <PropertyGroup>
-    <TargetFramework>netcoreapp2.2</TargetFramework>
+    <TargetFramework>netcoreapp3.0</TargetFramework>
     <OutputType>Exe</OutputType>
     <LangVersion>latest</LangVersion>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -22,8 +22,10 @@
 
   <ItemGroup>
     <PackageReference Include="Utf8Json" Version="1.3.7" />
-    <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
-    <PackageReference Include="RedHat.AspNetCore.Server.Kestrel.Transport.Linux" Version="2.2.0-*" />
+    <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.0.0-preview7.19362.4" />
+    <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.0.0-preview7.19362.4" />
+    <PackageReference Include="Microsoft.Extensions.Options" Version="3.0.0-preview7.19362.4" />
+    <!--PackageReference Include="RedHat.AspNetCore.Server.Kestrel.Transport.Linux" Version="2.2.0-*" /-->
     <PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-*" />
   </ItemGroup>
 </Project>

+ 5 - 10
frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/rd.xml

@@ -20,18 +20,13 @@
             <Type Name="Microsoft.Extensions.Options.OptionsFactory`1[[Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions,Microsoft.AspNetCore.Server.Kestrel.Core]]" Dynamic="Required All" />
             <Type Name="Microsoft.Extensions.Options.OptionsMonitor`1[[Microsoft.Extensions.Logging.Console.ConsoleLoggerOptions,Microsoft.Extensions.Logging.Console]]" Dynamic="Required All" />
         </Assembly>
-        <Assembly Name="Microsoft.AspNetCore.Http">
-            <Type Name="Microsoft.AspNetCore.Http.HttpContextFactory" Dynamic="Required All" />
-        </Assembly>
+        <Assembly Name="Microsoft.AspNetCore.Http" Dynamic="Required All" />
         <Assembly Name="Microsoft.AspNetCore.HostFiltering">
             <Type Name="Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware" Dynamic="Required All" />
         </Assembly>
-        <Assembly Name="Microsoft.AspNetCore.Hosting" Dynamic="Required All">
-            <Type Name="Microsoft.AspNetCore.Hosting.Internal.ApplicationLifetime" Dynamic="Required All" />
-            <Type Name="Microsoft.AspNetCore.Hosting.Internal.StartupLoader+ConfigureServicesDelegateBuilder`1[[System.Object,System.Private.CoreLib]]" Dynamic="Required All" />
-        </Assembly>
+        <Assembly Name="Microsoft.AspNetCore.Hosting" Dynamic="Required All" />
         <Assembly Name="Microsoft.Extensions.Logging.Abstractions">
-            <Type Name="Microsoft.Extensions.Logging.Logger`1[[Microsoft.AspNetCore.Hosting.Internal.WebHost,Microsoft.AspNetCore.Hosting]]" Dynamic="Required All" />
+
         </Assembly>
         <Assembly Name="Microsoft.Extensions.Logging">
             <Type Name="Microsoft.Extensions.Logging.LoggerFactory" Dynamic="Required All" />
@@ -44,8 +39,8 @@
         <Assembly Name="Microsoft.Extensions.Configuration.Json">
             <Type Name="Microsoft.Extensions.Configuration.Json.JsonConfigurationSource" Dynamic="Required All" />
         </Assembly>
-        <Assembly Name="RedHat.AspNetCore.Server.Kestrel.Transport.Linux">
+        <!--Assembly Name="RedHat.AspNetCore.Server.Kestrel.Transport.Linux">
             <Type Name="RedHat.AspNetCore.Server.Kestrel.Transport.Linux.LinuxTransportFactory" Dynamic="Required All" />
-        </Assembly>
+        </Assembly-->
     </Application>
 </Directives>

+ 5 - 2
frameworks/CSharp/aspnetcore-corert/aspcore-corert.dockerfile

@@ -3,11 +3,14 @@ RUN echo "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.9 main" | tee
 RUN wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | apt-key add -
 RUN apt-get update
 RUN apt-get -yqq install cmake clang-3.9 libicu57 libunwind8 uuid-dev libcurl4-openssl-dev zlib1g-dev libkrb5-dev
+RUN wget https://download.visualstudio.microsoft.com/download/pr/a0e368ac-7161-4bde-a139-1a3ef5a82bbe/439cdbb58950916d3718771c5d986c35/dotnet-sdk-3.0.100-preview8-013656-linux-x64.tar.gz
+RUN mkdir -p /dotnet
+RUN tar zxf dotnet-sdk-3.0.100-preview8-013656-linux-x64.tar.gz -C /dotnet
 WORKDIR /app
 COPY PlatformBenchmarks .
-RUN dotnet publish -c Release -o out -r linux-x64
+RUN /dotnet/dotnet publish -c Release -o out -r linux-x64
 
-FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS runtime
+FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime
 WORKDIR /app
 COPY --from=build /app/out ./
 

+ 0 - 19
frameworks/CSharp/aspnetcore-corert/benchmark_config.json

@@ -19,25 +19,6 @@
       "display_name": "ASP.NET Core",
       "notes": "",
       "versus": "aspcore"
-    },
-    "rhtx": {
-      "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, Red Hat Linux Transport",
-      "notes": "",
-      "versus": "aspcore"
     }
   }]
 }