Commit 4fe6bb2d authored by Nick Craver's avatar Nick Craver

DebuggAids: remove ResultBox bits

We'll be using BenchmarkDotNet for this going forward
parent e8d90569
......@@ -72,9 +72,6 @@ public void MassiveBulkOpsSync(int threads)
RedisKey key = "MBOS";
var conn = muxer.GetDatabase();
conn.KeyDelete(key, CommandFlags.FireAndForget);
#if DEBUG
long oldAlloc = ConnectionMultiplexer.GetResultBoxAllocationCount();
#endif
var timeTaken = RunConcurrent(delegate
{
for (int i = 0; i < workPerThread; i++)
......@@ -87,11 +84,6 @@ public void MassiveBulkOpsSync(int threads)
Assert.Equal(workPerThread * threads, val);
Log("{2}: Time for {0} ops on {3} threads: {1}ms (any order); ops/s: {4}",
threads * workPerThread, timeTaken.TotalMilliseconds, Me(), threads, (workPerThread * threads) / timeTaken.TotalSeconds);
#if DEBUG
long newAlloc = ConnectionMultiplexer.GetResultBoxAllocationCount();
Log("ResultBox allocations: {0}", newAlloc - oldAlloc);
Assert.True(newAlloc - oldAlloc <= 2 * threads, "number of box allocations");
#endif
}
}
......@@ -102,9 +94,6 @@ public void MassiveBulkOpsFireAndForget(int threads)
{
using (var muxer = Create(syncTimeout: 30000))
{
#if DEBUG
long oldAlloc = ConnectionMultiplexer.GetResultBoxAllocationCount();
#endif
RedisKey key = "MBOF";
var conn = muxer.GetDatabase();
conn.Ping();
......@@ -125,12 +114,6 @@ public void MassiveBulkOpsFireAndForget(int threads)
Log("{2}: Time for {0} ops over {4} threads: {1:###,###}ms (any order); ops/s: {3:###,###,##0}",
val, elapsed.TotalMilliseconds, Me(),
val / elapsed.TotalSeconds, threads);
#if DEBUG
long newAlloc = ConnectionMultiplexer.GetResultBoxAllocationCount();
Log("ResultBox allocations: {0}",
newAlloc - oldAlloc);
Assert.True(newAlloc - oldAlloc <= 4);
#endif
}
}
}
......
......@@ -19,9 +19,6 @@ public void MassiveBulkOpsFireAndForgetSecure()
{
using (var muxer = Create())
{
#if DEBUG
long oldAlloc = ConnectionMultiplexer.GetResultBoxAllocationCount();
#endif
RedisKey key = "MBOF";
var conn = muxer.GetDatabase();
conn.Ping();
......@@ -37,11 +34,6 @@ public void MassiveBulkOpsFireAndForgetSecure()
watch.Stop();
Log("{2}: Time for {0} ops: {1}ms (any order); ops/s: {3}", AsyncOpsQty, watch.ElapsedMilliseconds, Me(),
AsyncOpsQty / watch.Elapsed.TotalSeconds);
#if DEBUG
long newAlloc = ConnectionMultiplexer.GetResultBoxAllocationCount();
Log("ResultBox allocations: {0}", newAlloc - oldAlloc);
Assert.True(newAlloc - oldAlloc <= 2, $"NewAllocs: {newAlloc}, OldAllocs: {oldAlloc}");
#endif
}
}
......
......@@ -5,13 +5,6 @@
namespace StackExchange.Redis
{
#if DEBUG
internal partial class ResultBox
{
internal static long allocations;
public static long GetAllocationCount() => System.Threading.Interlocked.Read(ref allocations);
static partial void OnAllocated() => System.Threading.Interlocked.Increment(ref allocations);
}
public partial interface IServer
{
/// <summary>
......@@ -37,11 +30,6 @@ internal partial class RedisServer
public partial class ConnectionMultiplexer
{
/// <summary>
/// Gets how many result-box instances were allocated
/// </summary>
public static long GetResultBoxAllocationCount() => ResultBox.GetAllocationCount();
private volatile bool allowConnect = true,
ignoreConnect = false;
......
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace StackExchange.Redis
{
internal abstract partial class ResultBox
internal abstract class ResultBox
{
protected Exception _exception;
public abstract bool IsAsync { get; }
......@@ -15,14 +14,6 @@ internal abstract partial class ResultBox
public abstract bool TryComplete(bool isAsync);
[Conditional("DEBUG")]
protected static void IncrementAllocationCount()
{
OnAllocated();
}
static partial void OnAllocated();
public void Cancel() => _exception = s_cancelled;
// in theory nobody should directly observe this; the only things
......@@ -54,7 +45,6 @@ public static ResultBox<T> Get(object stateOrCompletionSource)
return found;
}
}
IncrementAllocationCount();
return new ResultBox<T>(stateOrCompletionSource);
}
......
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