Skip to content

Commit

Permalink
Improve aspcore DB benchmarks (TechEmpower#4015)
Browse files Browse the repository at this point in the history
* Update .NET MySQL benchmarks to latest MySqlConnector version.

* Update optimized connection string settings for MySqlConnector.

* Use prepared commands with MySqlConnector.

* Update npgsql to latest version.
  • Loading branch information
bgrainger authored and roberthusak committed Nov 6, 2018
1 parent e0c6e25 commit 038b927
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 26 deletions.
27 changes: 13 additions & 14 deletions frameworks/CSharp/aspnetcore-mono/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.0-rc1-final" />
<!-- Fix https://github.com/aspnet/KestrelHttpServer/pull/2562 -->
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets" Version="2.1.0-rtm-30793" />
<PackageReference Include="MySqlConnector" Version="0.40.3" />
<PackageReference Include="Npgsql" Version="4.0.0-rc1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.0-rc1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets" Version="2.1.3" />
<PackageReference Include="MySqlConnector" Version="0.44.1" />
<PackageReference Include="Npgsql" Version="4.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.1.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net471' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.1.0-rc1-final" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.0-rc1-final" />
<PackageReference Include="Utf8Json" Version="1.3.7" />
<PackageReference Include="Npgsql" Version="4.0.0-rc1" />
<PackageReference Include="MySqlConnector" Version="0.40.3" />
<PackageReference Include="Npgsql" Version="4.0.2" />
<PackageReference Include="MySqlConnector" Version="0.44.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net471' ">
Expand Down
6 changes: 3 additions & 3 deletions frameworks/CSharp/aspnetcore/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Dapper" Version="1.50.4" />
<PackageReference Include="MySqlConnector" Version="0.40.3" />
<PackageReference Include="Npgsql" Version="4.0.0-rc1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.0-rc1" />
<PackageReference Include="MySqlConnector" Version="0.44.1" />
<PackageReference Include="Npgsql" Version="4.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.1.1" />
<PackageReference Include="SpanJson" Version="1.2.2" />
<PackageReference Include="Utf8Json" Version="1.3.7" />
</ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions frameworks/CSharp/aspnetcore/Benchmarks/Data/RawDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ DbCommand CreateReadCommand(DbConnection connection)
id.Value = _random.Next(1, 10001);
cmd.Parameters.Add(id);

(cmd as MySql.Data.MySqlClient.MySqlCommand)?.Prepare();

return cmd;
}

Expand Down Expand Up @@ -147,6 +149,8 @@ public async Task<IEnumerable<Fortune>> LoadFortunesRows()
db.ConnectionString = _connectionString;
await db.OpenAsync();

(cmd as MySql.Data.MySqlClient.MySqlCommand)?.Prepare();

using (var rdr = await cmd.ExecuteReaderAsync(CommandBehavior.CloseConnection))
{
while (await rdr.ReadAsync())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"ConnectionString": "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=1024;SslMode=None;ConnectionReset=false;ConnectionIdlePingTime=900;ConnectionIdleTimeout=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"
}
4 changes: 4 additions & 0 deletions frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/RawDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ DbCommand CreateReadCommand(DbConnection connection)
id.Value = _random.Next(1, 10001);
cmd.Parameters.Add(id);

(cmd as MySql.Data.MySqlClient.MySqlCommand)?.Prepare();

return cmd;
}

Expand Down Expand Up @@ -146,6 +148,8 @@ public async Task<List<Fortune>> LoadFortunesRows()
db.ConnectionString = _connectionString;
await db.OpenAsync();

(cmd as MySql.Data.MySqlClient.MySqlCommand)?.Prepare();

using (var rdr = await cmd.ExecuteReaderAsync(CommandBehavior.CloseConnection))
{
while (await rdr.ReadAsync())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

<ItemGroup>
<PackageReference Include="Utf8Json" Version="1.3.7" />
<PackageReference Include="Npgsql" Version="4.0.0-rc1" />
<PackageReference Include="MySqlConnector" Version="0.40.3" />
<PackageReference Include="Npgsql" Version="4.0.2" />
<PackageReference Include="MySqlConnector" Version="0.44.1" />
<PackageReference Include="Microsoft.AspNetCore.All" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion frameworks/CSharp/nancy/src/NancyBenchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<ItemGroup>
<PackageReference Include="Nancy" Version="2.0.0-pre1909" />
<PackageReference Include="MySqlConnector" Version="0.40.3" />
<PackageReference Include="MySqlConnector" Version="0.44.1" />
<PackageReference Include="Dapper" Version="1.50.4" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions frameworks/VB/aspnetcore/Benchmarks/Benchmarks.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

<ItemGroup>
<PackageReference Include="Utf8Json" Version="1.3.7" />
<PackageReference Include="Npgsql" Version="4.0.1" />
<PackageReference Include="MySqlConnector" Version="0.42.2" />
<PackageReference Include="Npgsql" Version="4.0.2" />
<PackageReference Include="MySqlConnector" Version="0.44.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion frameworks/VB/aspnetcore/Benchmarks/appsettings.mysql.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"ConnectionString": "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=1024;SslMode=None;ConnectionReset=false;ConnectionIdlePingTime=900;ConnectionIdleTimeout=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;",
"Database": "mysql"
}

0 comments on commit 038b927

Please sign in to comment.