Browse Source

[aspnetcore-corert] Synchronize with aspnetcore (#6975)

* Synchronizes source files and package references with aspnetcore.
* RD.XML no longer needed.
* Enable SSE 4.2 intrinsics (Json has meaningful differences because of a hand-tuned SSSE3 implementation, but bumping all the way to 4.2 because why not).
Michal Strehovský 3 years ago
parent
commit
84aa6516e1

+ 5 - 5
frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Providers/RawDbMySqlConnector.cs

@@ -19,8 +19,8 @@ namespace PlatformBenchmarks
     {
         private readonly ConcurrentRandom _random;
         private readonly string _connectionString;
-        private readonly MemoryCache _cache = new MemoryCache(
-            new MemoryCacheOptions()
+        private readonly MemoryCache _cache = new(
+            new MemoryCacheOptions
             {
                 ExpirationScanFrequency = TimeSpan.FromMinutes(60)
             });
@@ -98,7 +98,7 @@ namespace PlatformBenchmarks
                     var (cmd, idParameter) = await rawdb.CreateReadCommandAsync(db);
                     using (cmd)
                     {
-                        Func<ICacheEntry, Task<CachedWorld>> create = async (entry) =>
+                        Func<ICacheEntry, Task<CachedWorld>> create = async _ =>
                         {
                             return await rawdb.ReadSingleRow(cmd);
                         };
@@ -110,7 +110,7 @@ namespace PlatformBenchmarks
 
                         for (; i < result.Length; i++)
                         {
-                            result[i] = await rawdb._cache.GetOrCreateAsync<CachedWorld>(key, create);
+                            result[i] = await rawdb._cache.GetOrCreateAsync(key, create);
 
                             id = rawdb._random.Next(1, 10001);
                             idParameter.Value = id;
@@ -245,7 +245,7 @@ namespace PlatformBenchmarks
             }
         }
         
-        private static readonly object[] _cacheKeys = Enumerable.Range(0, 10001).Select((i) => new CacheKey(i)).ToArray();
+        private static readonly object[] _cacheKeys = Enumerable.Range(0, 10001).Select(i => new CacheKey(i)).ToArray();
 
         public sealed class CacheKey : IEquatable<CacheKey>
         {

+ 7 - 7
frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/Data/Providers/RawDbNpgsql.cs

@@ -19,8 +19,8 @@ namespace PlatformBenchmarks
     {
         private readonly ConcurrentRandom _random;
         private readonly string _connectionString;
-        private readonly MemoryCache _cache = new MemoryCache(
-            new MemoryCacheOptions()
+        private readonly MemoryCache _cache = new(
+            new MemoryCacheOptions
             {
                 ExpirationScanFrequency = TimeSpan.FromMinutes(60)
             });
@@ -98,7 +98,7 @@ namespace PlatformBenchmarks
                     var (cmd, idParameter) = rawdb.CreateReadCommand(db);
                     using (cmd)
                     {
-                        Func<ICacheEntry, Task<CachedWorld>> create = async (entry) =>
+                        Func<ICacheEntry, Task<CachedWorld>> create = async _ =>
                         {
                             return await rawdb.ReadSingleRow(cmd);
                         };
@@ -110,7 +110,7 @@ namespace PlatformBenchmarks
 
                         for (; i < result.Length; i++)
                         {
-                            result[i] = await rawdb._cache.GetOrCreateAsync<CachedWorld>(key, create);
+                            result[i] = await rawdb._cache.GetOrCreateAsync(key, create);
 
                             id = rawdb._random.Next(1, 10001);
                             idParameter.TypedValue = id;
@@ -215,8 +215,8 @@ namespace PlatformBenchmarks
 
         private (NpgsqlCommand readCmd, NpgsqlParameter<int> idParameter) CreateReadCommand(NpgsqlConnection connection)
         {
-            var cmd = new NpgsqlCommand("SELECT id, randomnumber FROM world WHERE id = @Id", connection);
-            var parameter = new NpgsqlParameter<int>(parameterName: "@Id", value: _random.Next(1, 10001));
+            var cmd = new NpgsqlCommand("SELECT id, randomnumber FROM world WHERE id = $1", connection);
+            var parameter = new NpgsqlParameter<int> { TypedValue = _random.Next(1, 10001) };
 
             cmd.Parameters.Add(parameter);
 
@@ -238,7 +238,7 @@ namespace PlatformBenchmarks
             }
         }
 
-        private static readonly object[] _cacheKeys = Enumerable.Range(0, 10001).Select((i) => new CacheKey(i)).ToArray();
+        private static readonly object[] _cacheKeys = Enumerable.Range(0, 10001).Select(i => new CacheKey(i)).ToArray();
 
         public sealed class CacheKey : IEquatable<CacheKey>
         {

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

@@ -24,8 +24,8 @@
   </PropertyGroup>
   
   <ItemGroup>
-    <PackageReference Condition=" '$(DatabaseProvider)' == 'Npgsql' " Include="Npgsql" Version="6.0.0-preview4" />
-    <PackageReference Condition=" '$(DatabaseProvider)' == 'MySqlConnector' " Include="MySqlConnector" Version="1.3.12" />
+    <PackageReference Condition=" '$(DatabaseProvider)' == 'Npgsql' " Include="Npgsql" Version="6.0.0-rc.2" />
+    <PackageReference Condition=" '$(DatabaseProvider)' == 'MySqlConnector' " Include="MySqlConnector" Version="1.3.13" />
     <PackageReference Include="Microsoft.DotNet.ILCompiler" Version="7.0.0-*" />
   </ItemGroup>
 
@@ -34,7 +34,7 @@
   </ItemGroup>
 
   <ItemGroup>
-    <RdXmlFile Condition=" '$(DatabaseProvider)' == 'Npgsql' " Include="npgsql.rd.xml" />
+    <IlcArg Include="--instructionset:sse4.2" />
   </ItemGroup>
 
 </Project>

+ 1 - 1
frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.postgresql.json

@@ -1,4 +1,4 @@
 {
-  "ConnectionString": "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=18;Enlist=false;Max Auto Prepare=4;Multiplexing=true;Write Coalescing Buffer Threshold Bytes=1000",
+  "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"
 }

+ 1 - 1
frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/appsettings.postgresql.updates.json

@@ -1,4 +1,4 @@
 {
-  "ConnectionString": "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=18;Enlist=false;Max Auto Prepare=4;Multiplexing=true;Write Coalescing Buffer Threshold Bytes=1000",  
+  "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"
 }

+ 0 - 51
frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/npgsql.rd.xml

@@ -1,51 +0,0 @@
-<Directives>
-  <Application>
-    <Assembly Name="Npgsql">
-      <Type Name="Npgsql.Internal.TypeHandlers.NetworkHandlers.InetHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.DateTimeHandlers.DateHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.DateTimeHandlers.IntervalHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.DateTimeHandlers.TimestampTzHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.BoolHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.EnumHandler`1" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.UuidHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.VoidHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.NumericHandlers.DoubleHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.NumericHandlers.Int16Handler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.NumericHandlers.Int32Handler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.NumericHandlers.Int64Handler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.NumericHandlers.MoneyHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.NumericHandlers.SingleHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.NumericHandlers.UInt32Handler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.NetworkHandlers.CidrHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.NetworkHandlers.MacaddrHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.InternalTypeHandlers.InternalCharHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.InternalTypeHandlers.PgLsnHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.InternalTypeHandlers.TidHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.GeometricHandlers.BoxHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.GeometricHandlers.CircleHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.GeometricHandlers.LineHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.GeometricHandlers.LineSegmentHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.GeometricHandlers.PointHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.DateTimeHandlers.TimeHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.DateTimeHandlers.TimeTzHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.BitStringHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.ByteaHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.HstoreHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.JsonHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.JsonPathHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.RangeHandler`2" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.RecordHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.UnknownTypeHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.UnmappedEnumHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.LTreeHandlers.LQueryHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.LTreeHandlers.LTreeHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.LTreeHandlers.LTxtQueryHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.NumericHandlers.NumericHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.GeometricHandlers.PathHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.GeometricHandlers.PolygonHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.FullTextSearchHandlers.TsQueryHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.FullTextSearchHandlers.TsVectorHandler" Dynamic="Required All" />
-      <Type Name="Npgsql.Internal.TypeHandlers.CompositeHandlers.CompositeHandler`1" Dynamic="Required All" />
-    </Assembly>
-  </Application>
-</Directives>