Commit 3fef93d2 authored by Marc Gravell's avatar Marc Gravell

attempting to investigate perf pain

parent 10328be0
...@@ -112,6 +112,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{153A10E4-E ...@@ -112,6 +112,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{153A10E4-E
docs\Transactions.md = docs\Transactions.md docs\Transactions.md = docs\Transactions.md
EndProjectSection EndProjectSection
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestConsoleBaseline", "toys\TestConsoleBaseline\TestConsoleBaseline.csproj", "{D58114AE-4998-4647-AFCA-9353D20495AE}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
...@@ -154,6 +156,10 @@ Global ...@@ -154,6 +156,10 @@ Global
{3DA1EEED-E9FE-43D9-B293-E000CFCCD91A}.Debug|Any CPU.Build.0 = Debug|Any CPU {3DA1EEED-E9FE-43D9-B293-E000CFCCD91A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DA1EEED-E9FE-43D9-B293-E000CFCCD91A}.Release|Any CPU.ActiveCfg = Release|Any CPU {3DA1EEED-E9FE-43D9-B293-E000CFCCD91A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3DA1EEED-E9FE-43D9-B293-E000CFCCD91A}.Release|Any CPU.Build.0 = Release|Any CPU {3DA1EEED-E9FE-43D9-B293-E000CFCCD91A}.Release|Any CPU.Build.0 = Release|Any CPU
{D58114AE-4998-4647-AFCA-9353D20495AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D58114AE-4998-4647-AFCA-9353D20495AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D58114AE-4998-4647-AFCA-9353D20495AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D58114AE-4998-4647-AFCA-9353D20495AE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
...@@ -173,6 +179,7 @@ Global ...@@ -173,6 +179,7 @@ Global
{D082703F-1652-4C35-840D-7D377F6B9979} = {96E891CD-2ED7-4293-A7AB-4C6F5D8D2B05} {D082703F-1652-4C35-840D-7D377F6B9979} = {96E891CD-2ED7-4293-A7AB-4C6F5D8D2B05}
{8375813E-FBAF-4DA3-A2C7-E4645B39B931} = {E25031D3-5C64-430D-B86F-697B66816FD8} {8375813E-FBAF-4DA3-A2C7-E4645B39B931} = {E25031D3-5C64-430D-B86F-697B66816FD8}
{3DA1EEED-E9FE-43D9-B293-E000CFCCD91A} = {E25031D3-5C64-430D-B86F-697B66816FD8} {3DA1EEED-E9FE-43D9-B293-E000CFCCD91A} = {E25031D3-5C64-430D-B86F-697B66816FD8}
{D58114AE-4998-4647-AFCA-9353D20495AE} = {E25031D3-5C64-430D-B86F-697B66816FD8}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {193AA352-6748-47C1-A5FC-C9AA6B5F000B} SolutionGuid = {193AA352-6748-47C1-A5FC-C9AA6B5F000B}
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<Description>StackExchange.Redis.BasicTest .NET Core</Description> <Description>StackExchange.Redis.BasicTest .NET Core</Description>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1;net47</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;netcoreapp2.1;net472</TargetFrameworks>
<AssemblyName>BasicTest</AssemblyName> <AssemblyName>BasicTest</AssemblyName>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<PackageId>BasicTest</PackageId> <PackageId>BasicTest</PackageId>
......
...@@ -21,7 +21,8 @@ internal class CustomConfig : ManualConfig ...@@ -21,7 +21,8 @@ internal class CustomConfig : ManualConfig
{ {
protected virtual Job Configure(Job j) protected virtual Job Configure(Job j)
=> j.With(new GcMode { Force = true }) => j.With(new GcMode { Force = true })
.With(InProcessToolchain.Instance); .With(InProcessToolchain.Instance)
;
public CustomConfig() public CustomConfig()
{ {
...@@ -54,8 +55,11 @@ public class RedisBenchmarks : IDisposable ...@@ -54,8 +55,11 @@ public class RedisBenchmarks : IDisposable
/// <summary> /// <summary>
/// Create /// Create
/// </summary> /// </summary>
public RedisBenchmarks() [GlobalSetup]
public void Setup()
{ {
// Pipelines.Sockets.Unofficial.SocketConnection.AssertDependencies();
var options = ConfigurationOptions.Parse("127.0.0.1:6379"); var options = ConfigurationOptions.Parse("127.0.0.1:6379");
connection = ConnectionMultiplexer.Connect(options); connection = ConnectionMultiplexer.Connect(options);
db = connection.GetDatabase(3); db = connection.GetDatabase(3);
...@@ -80,9 +84,9 @@ void IDisposable.Dispose() ...@@ -80,9 +84,9 @@ void IDisposable.Dispose()
/// Run INCRBY lots of times /// Run INCRBY lots of times
/// </summary> /// </summary>
#if TEST_BASELINE #if TEST_BASELINE
[Benchmark(Description = "INCRBY:v1/s", OperationsPerInvoke = COUNT)] // [Benchmark(Description = "INCRBY:v1/s", OperationsPerInvoke = COUNT)]
#else #else
[Benchmark(Description = "INCRBY:v2/s", OperationsPerInvoke = COUNT)] // [Benchmark(Description = "INCRBY:v2/s", OperationsPerInvoke = COUNT)]
#endif #endif
public int ExecuteIncrBy() public int ExecuteIncrBy()
{ {
...@@ -105,9 +109,9 @@ public int ExecuteIncrBy() ...@@ -105,9 +109,9 @@ public int ExecuteIncrBy()
/// Run INCRBY lots of times /// Run INCRBY lots of times
/// </summary> /// </summary>
#if TEST_BASELINE #if TEST_BASELINE
[Benchmark(Description = "INCRBY:v1/a", OperationsPerInvoke = COUNT)] // [Benchmark(Description = "INCRBY:v1/a", OperationsPerInvoke = COUNT)]
#else #else
[Benchmark(Description = "INCRBY:v2/a", OperationsPerInvoke = COUNT)] // [Benchmark(Description = "INCRBY:v2/a", OperationsPerInvoke = COUNT)]
#endif #endif
public async Task<int> ExecuteIncrByAsync() public async Task<int> ExecuteIncrByAsync()
{ {
...@@ -130,9 +134,9 @@ public async Task<int> ExecuteIncrByAsync() ...@@ -130,9 +134,9 @@ public async Task<int> ExecuteIncrByAsync()
/// Run GEORADIUS lots of times /// Run GEORADIUS lots of times
/// </summary> /// </summary>
#if TEST_BASELINE #if TEST_BASELINE
[Benchmark(Description = "GEORADIUS:v1/s", OperationsPerInvoke = COUNT)] // [Benchmark(Description = "GEORADIUS:v1/s", OperationsPerInvoke = COUNT)]
#else #else
[Benchmark(Description = "GEORADIUS:v2/s", OperationsPerInvoke = COUNT)] // [Benchmark(Description = "GEORADIUS:v2/s", OperationsPerInvoke = COUNT)]
#endif #endif
public int ExecuteGeoRadius() public int ExecuteGeoRadius()
{ {
...@@ -150,9 +154,9 @@ public int ExecuteGeoRadius() ...@@ -150,9 +154,9 @@ public int ExecuteGeoRadius()
/// Run GEORADIUS lots of times /// Run GEORADIUS lots of times
/// </summary> /// </summary>
#if TEST_BASELINE #if TEST_BASELINE
[Benchmark(Description = "GEORADIUS:v1/a", OperationsPerInvoke = COUNT)] // [Benchmark(Description = "GEORADIUS:v1/a", OperationsPerInvoke = COUNT)]
#else #else
[Benchmark(Description = "GEORADIUS:v2/a", OperationsPerInvoke = COUNT)] // [Benchmark(Description = "GEORADIUS:v2/a", OperationsPerInvoke = COUNT)]
#endif #endif
public async Task<int> ExecuteGeoRadiusAsync() public async Task<int> ExecuteGeoRadiusAsync()
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<Description>StackExchange.Redis.BasicTest .NET Core</Description> <Description>StackExchange.Redis.BasicTest .NET Core</Description>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1;net47</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;netcoreapp2.1;net472</TargetFrameworks>
<AssemblyName>BasicTestBaseline</AssemblyName> <AssemblyName>BasicTestBaseline</AssemblyName>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<PackageId>BasicTestBaseline</PackageId> <PackageId>BasicTestBaseline</PackageId>
......
using System; using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks; using System.Threading.Tasks;
using StackExchange.Redis; using StackExchange.Redis;
namespace TestConsole static class Program
{ {
internal static class Program private static int taskCount = 10;
{ private static int totalRecords = 100000;
private static async Task Main()
{ static void Main()
using (var conn = Create())
{ {
var sub = conn.GetSubscriber();
Console.WriteLine("Subscsribe...");
sub.Subscribe("foo", (channel, value) => Console.WriteLine($"{channel}: {value}"));
Console.WriteLine("Ping...");
sub.Ping();
Console.WriteLine("Run publish...");
await RunPub().ConfigureAwait(false);
}
await Console.Out.WriteLineAsync("Waiting a minute...").ConfigureAwait(false); #if SEV2
await Task.Delay(60 * 1000).ConfigureAwait(false); Pipelines.Sockets.Unofficial.SocketConnection.AssertDependencies();
Console.WriteLine("We loaded the things...");
// Console.ReadLine();
#endif
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
var taskList = new List<Task>();
var connection = ConnectionMultiplexer.Connect("127.0.0.1", Console.Out);
for (int i = 0; i < taskCount; i++)
{
var i1 = i;
var task = new Task(() => Run(i1, connection));
task.Start();
taskList.Add(task);
} }
private static ConnectionMultiplexer Create() Task.WaitAll(taskList.ToArray());
{
var options = new ConfigurationOptions stopwatch.Stop();
{
KeepAlive = 5, Console.WriteLine($"Done. {stopwatch.ElapsedMilliseconds}");
EndPoints = { "localhost:6379" }, Console.ReadLine();
SyncTimeout = int.MaxValue,
// CommandMap = CommandMap.Create(new HashSet<string> { "subscribe", "psubscsribe", "publish" }, false),
};
Console.WriteLine("Connecting...");
var muxer = ConnectionMultiplexer.Connect(options, Console.Out);
Console.WriteLine("Connected");
muxer.ConnectionFailed += (_, a) => Console.WriteLine($"Failed: {a.ConnectionType}, {a.EndPoint}, {a.FailureType}, {a.Exception}");
muxer.ConnectionRestored += (_, a) => Console.WriteLine($"Restored: {a.ConnectionType}, {a.EndPoint}, {a.FailureType}, {a.Exception}");
Console.WriteLine("Ping...");
var time = muxer.GetDatabase().Ping();
Console.WriteLine($"Pinged: {time.TotalMilliseconds}ms");
return muxer;
} }
public static async Task RunPub() static void Run(int taskId, ConnectionMultiplexer connection)
{ {
using (var conn = Create()) Console.WriteLine($"{taskId} Started");
{ var database = connection.GetDatabase(0);
var pub = conn.GetSubscriber();
for (int i = 0; i < 100; i++) for (int i = 0; i < totalRecords; i++)
{ {
await pub.PublishAsync("foo", i).ConfigureAwait(false); database.StringSet(i.ToString(), i.ToString());
} }
await Console.Out.WriteLineAsync("Waiting a minute...").ConfigureAwait(false); Console.WriteLine($"{taskId} Insert completed");
await Task.Delay(60 * 1000).ConfigureAwait(false);
} for (int i = 0; i < totalRecords; i++)
{
var result = database.StringGet(i.ToString());
} }
Console.WriteLine($"{taskId} Completed");
} }
} }
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.1;net462;net47;net472</TargetFrameworks> <TargetFrameworks>netcoreapp2.1;net461;net462;net47;net472</TargetFrameworks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<DefineConstants>SEV2</DefineConstants>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Computername)'=='OCHO' or '$(Computername)'=='SKINK'"> <PropertyGroup Condition="'$(Computername)'=='OCHO' or '$(Computername)'=='SKINK'">
...@@ -14,6 +16,8 @@ ...@@ -14,6 +16,8 @@
<!--<ProjectReference Include="..\..\tests\BasicTest\BasicTest.csproj" /> <!--<ProjectReference Include="..\..\tests\BasicTest\BasicTest.csproj" />
<ProjectReference Include="..\StackExchange.Redis.Server\StackExchange.Redis.Server.csproj" /> <ProjectReference Include="..\StackExchange.Redis.Server\StackExchange.Redis.Server.csproj" />
<ProjectReference Include="..\..\tests\StackExchange.Redis.Tests\StackExchange.Redis.Tests.csproj" />--> <ProjectReference Include="..\..\tests\StackExchange.Redis.Tests\StackExchange.Redis.Tests.csproj" />-->
<ProjectReference Include="..\..\src\StackExchange.Redis\StackExchange.Redis.csproj" /> <!--<ProjectReference Include="..\..\src\StackExchange.Redis\StackExchange.Redis.csproj" />-->
<PackageReference Include="Pipelines.Sockets.Unofficial" Version="1.0.6" />
<PackageReference Include="StackExchange.Redis" Version="2.0.510" />
</ItemGroup> </ItemGroup>
</Project> </Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.1;net461;net462;net47;net472</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Computername)'=='OCHO' or '$(Computername)'=='SKINK'">
<LocalReference>true</LocalReference>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\TestConsole\Program.cs" Link="Program.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="StackExchange.Redis" Version="[1.2.7-alpha-00002]" />
</ItemGroup>
</Project>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment