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
docs\Transactions.md = docs\Transactions.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestConsoleBaseline", "toys\TestConsoleBaseline\TestConsoleBaseline.csproj", "{D58114AE-4998-4647-AFCA-9353D20495AE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -154,6 +156,10 @@ Global
{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.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
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......@@ -173,6 +179,7 @@ Global
{D082703F-1652-4C35-840D-7D377F6B9979} = {96E891CD-2ED7-4293-A7AB-4C6F5D8D2B05}
{8375813E-FBAF-4DA3-A2C7-E4645B39B931} = {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
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {193AA352-6748-47C1-A5FC-C9AA6B5F000B}
......
......@@ -2,7 +2,7 @@
<PropertyGroup>
<Description>StackExchange.Redis.BasicTest .NET Core</Description>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1;net47</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1;net472</TargetFrameworks>
<AssemblyName>BasicTest</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>BasicTest</PackageId>
......
......@@ -21,7 +21,8 @@ internal class CustomConfig : ManualConfig
{
protected virtual Job Configure(Job j)
=> j.With(new GcMode { Force = true })
.With(InProcessToolchain.Instance);
.With(InProcessToolchain.Instance)
;
public CustomConfig()
{
......@@ -54,8 +55,11 @@ public class RedisBenchmarks : IDisposable
/// <summary>
/// Create
/// </summary>
public RedisBenchmarks()
[GlobalSetup]
public void Setup()
{
// Pipelines.Sockets.Unofficial.SocketConnection.AssertDependencies();
var options = ConfigurationOptions.Parse("127.0.0.1:6379");
connection = ConnectionMultiplexer.Connect(options);
db = connection.GetDatabase(3);
......@@ -80,9 +84,9 @@ void IDisposable.Dispose()
/// Run INCRBY lots of times
/// </summary>
#if TEST_BASELINE
[Benchmark(Description = "INCRBY:v1/s", OperationsPerInvoke = COUNT)]
// [Benchmark(Description = "INCRBY:v1/s", OperationsPerInvoke = COUNT)]
#else
[Benchmark(Description = "INCRBY:v2/s", OperationsPerInvoke = COUNT)]
// [Benchmark(Description = "INCRBY:v2/s", OperationsPerInvoke = COUNT)]
#endif
public int ExecuteIncrBy()
{
......@@ -105,9 +109,9 @@ public int ExecuteIncrBy()
/// Run INCRBY lots of times
/// </summary>
#if TEST_BASELINE
[Benchmark(Description = "INCRBY:v1/a", OperationsPerInvoke = COUNT)]
// [Benchmark(Description = "INCRBY:v1/a", OperationsPerInvoke = COUNT)]
#else
[Benchmark(Description = "INCRBY:v2/a", OperationsPerInvoke = COUNT)]
// [Benchmark(Description = "INCRBY:v2/a", OperationsPerInvoke = COUNT)]
#endif
public async Task<int> ExecuteIncrByAsync()
{
......@@ -130,9 +134,9 @@ public async Task<int> ExecuteIncrByAsync()
/// Run GEORADIUS lots of times
/// </summary>
#if TEST_BASELINE
[Benchmark(Description = "GEORADIUS:v1/s", OperationsPerInvoke = COUNT)]
// [Benchmark(Description = "GEORADIUS:v1/s", OperationsPerInvoke = COUNT)]
#else
[Benchmark(Description = "GEORADIUS:v2/s", OperationsPerInvoke = COUNT)]
// [Benchmark(Description = "GEORADIUS:v2/s", OperationsPerInvoke = COUNT)]
#endif
public int ExecuteGeoRadius()
{
......@@ -150,9 +154,9 @@ public int ExecuteGeoRadius()
/// Run GEORADIUS lots of times
/// </summary>
#if TEST_BASELINE
[Benchmark(Description = "GEORADIUS:v1/a", OperationsPerInvoke = COUNT)]
// [Benchmark(Description = "GEORADIUS:v1/a", OperationsPerInvoke = COUNT)]
#else
[Benchmark(Description = "GEORADIUS:v2/a", OperationsPerInvoke = COUNT)]
// [Benchmark(Description = "GEORADIUS:v2/a", OperationsPerInvoke = COUNT)]
#endif
public async Task<int> ExecuteGeoRadiusAsync()
{
......
......@@ -2,7 +2,7 @@
<PropertyGroup>
<Description>StackExchange.Redis.BasicTest .NET Core</Description>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1;net47</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;netcoreapp2.1;net472</TargetFrameworks>
<AssemblyName>BasicTestBaseline</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>BasicTestBaseline</PackageId>
......
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using StackExchange.Redis;
namespace TestConsole
static class Program
{
internal static class Program
private static int taskCount = 10;
private static int totalRecords = 100000;
static void Main()
{
private static async Task Main()
#if SEV2
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++)
{
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);
await Task.Delay(60 * 1000).ConfigureAwait(false);
var i1 = i;
var task = new Task(() => Run(i1, connection));
task.Start();
taskList.Add(task);
}
private static ConnectionMultiplexer Create()
Task.WaitAll(taskList.ToArray());
stopwatch.Stop();
Console.WriteLine($"Done. {stopwatch.ElapsedMilliseconds}");
Console.ReadLine();
}
static void Run(int taskId, ConnectionMultiplexer connection)
{
Console.WriteLine($"{taskId} Started");
var database = connection.GetDatabase(0);
for (int i = 0; i < totalRecords; i++)
{
var options = new ConfigurationOptions
{
KeepAlive = 5,
EndPoints = { "localhost:6379" },
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;
database.StringSet(i.ToString(), i.ToString());
}
public static async Task RunPub()
Console.WriteLine($"{taskId} Insert completed");
for (int i = 0; i < totalRecords; i++)
{
using (var conn = Create())
{
var pub = conn.GetSubscriber();
for (int i = 0; i < 100; i++)
{
await pub.PublishAsync("foo", i).ConfigureAwait(false);
}
await Console.Out.WriteLineAsync("Waiting a minute...").ConfigureAwait(false);
await Task.Delay(60 * 1000).ConfigureAwait(false);
}
var result = database.StringGet(i.ToString());
}
Console.WriteLine($"{taskId} Completed");
}
}
......@@ -2,18 +2,22 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.1;net462;net47;net472</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;net461;net462;net47;net472</TargetFrameworks>
<LangVersion>latest</LangVersion>
<DefineConstants>SEV2</DefineConstants>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition="'$(Computername)'=='OCHO' or '$(Computername)'=='SKINK'">
<LocalReference>true</LocalReference>
</PropertyGroup>
<ItemGroup>
<!--<ProjectReference Include="..\..\tests\BasicTest\BasicTest.csproj" />
<ProjectReference Include="..\StackExchange.Redis.Server\StackExchange.Redis.Server.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>
</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