Bladeren bron

aspnetcore: add platform multiple queries and tweak postgresql connectionstring (#4303)

* aspcore: add platform multiple queries

* Add missing console output

* tweak postgresql connectionstring
n-stefan 6 jaren geleden
bovenliggende
commit
26e988840e

+ 1 - 1
frameworks/CSharp/aspnetcore/Benchmarks/appsettings.postgresql.json

@@ -1,4 +1,4 @@
 {
-  "ConnectionString": "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=1024;NoResetOnClose=true;Enlist=false;Max Auto Prepare=3",
+  "ConnectionString": "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=64;NoResetOnClose=true;Enlist=false;Max Auto Prepare=3",
   "Database": "postgresql"
 }

+ 47 - 0
frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.MultipleQueries.cs

@@ -0,0 +1,47 @@
+// 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 System.Threading.Tasks;
+using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
+using Utf8Json;
+
+namespace PlatformBenchmarks
+{
+    public partial class BenchmarkApplication
+    {
+        private async Task MultipleQueries(PipeWriter pipeWriter, int count)
+        {
+            OutputMultipleQueries(pipeWriter, await Db.LoadMultipleQueriesRows(count));
+        }
+
+        private static void OutputMultipleQueries(PipeWriter pipeWriter, World[] rows)
+        {
+            var writer = GetWriter(pipeWriter);
+
+            // HTTP 1.1 OK
+            writer.Write(_http11OK);
+
+            // Server headers
+            writer.Write(_headerServer);
+
+            // Date header
+            writer.Write(DateHeader.HeaderBytes);
+
+            // Content-Type header
+            writer.Write(_headerContentTypeJson);
+
+            // Content-Length header
+            writer.Write(_headerContentLength);
+            var jsonPayload = JsonSerializer.SerializeUnsafe(rows);
+            writer.WriteNumeric((uint)jsonPayload.Count);
+
+            // End of headers
+            writer.Write(_eoh);
+
+            // Body
+            writer.Write(jsonPayload);
+            writer.Commit();
+        }
+    }
+}

+ 15 - 4
frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs

@@ -42,6 +42,7 @@ namespace PlatformBenchmarks
             public readonly static AsciiString Fortunes = "/fortunes";
             public readonly static AsciiString Plaintext = "/plaintext";
             public readonly static AsciiString Updates = "/updates/queries=";
+            public readonly static AsciiString MultipleQueries = "/queries/queries=";
         }
 
         private RequestType _requestType;
@@ -71,17 +72,22 @@ namespace PlatformBenchmarks
                 }
                 else if (Paths.Updates.Length <= pathLength && path.StartsWith(Paths.Updates))
                 {
-                    _queries = ParseQueries(path);
+                    _queries = ParseQueries(path, Paths.Updates.Length);
                     requestType = RequestType.Updates;
                 }
+                else if (Paths.MultipleQueries.Length <= pathLength && path.StartsWith(Paths.MultipleQueries))
+                {
+                    _queries = ParseQueries(path, Paths.MultipleQueries.Length);
+                    requestType = RequestType.MultipleQueries;
+                }
             }
 
             _requestType = requestType;
         }
 
-        private static int ParseQueries(Span<byte> path)
+        private static int ParseQueries(Span<byte> path, int pathLength)
         {
-            if (!Utf8Parser.TryParse(path.Slice(Paths.Updates.Length), out int queries, out _) || queries < 1)
+            if (!Utf8Parser.TryParse(path.Slice(pathLength), out int queries, out _) || queries < 1)
             {
                 queries = 1;
             }
@@ -117,6 +123,10 @@ namespace PlatformBenchmarks
             {
                 task = Updates(Writer, _queries);
             }
+            else if (requestType == RequestType.MultipleQueries)
+            {
+                task = MultipleQueries(Writer, _queries);
+            }
             else
             {
                 Default(Writer);
@@ -153,7 +163,8 @@ namespace PlatformBenchmarks
             Json,
             Fortunes,
             SingleQuery,
-            Updates
+            Updates,
+            MultipleQueries
         }
     }
 }

+ 1 - 0
frameworks/CSharp/aspnetcore/PlatformBenchmarks/Program.cs

@@ -25,6 +25,7 @@ namespace PlatformBenchmarks
             Console.WriteLine(BenchmarkApplication.Paths.Fortunes);
             Console.WriteLine(BenchmarkApplication.Paths.SingleQuery);
             Console.WriteLine(BenchmarkApplication.Paths.Updates);
+            Console.WriteLine(BenchmarkApplication.Paths.MultipleQueries);
             DateHeader.SyncDateTimer();
             BatchUpdateString.Initalize();
 

+ 3 - 0
frameworks/CSharp/aspnetcore/benchmark_config.json

@@ -43,6 +43,7 @@
       "fortune_url": "/fortunes",
       "db_url": "/db",
       "update_url": "/updates/queries=",
+      "query_url": "/queries/queries=",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Platform",
@@ -63,6 +64,7 @@
       "fortune_url": "/fortunes",
       "db_url": "/db",
       "update_url": "/updates/queries=",
+      "query_url": "/queries/queries=",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Platform",
@@ -83,6 +85,7 @@
       "fortune_url": "/fortunes",
       "db_url": "/db",
       "update_url": "/updates/queries=",
+      "query_url": "/queries/queries=",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Platform",