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