Commit 0e031eee authored by mgravell's avatar mgravell

track the time to get a backlog processor, and the time to get the lock

parent 73d087d6
...@@ -283,9 +283,10 @@ void add(string lk, string sk, string v) ...@@ -283,9 +283,10 @@ void add(string lk, string sk, string v)
}; };
if (data != null) if (data != null)
{ {
var exData = ex.Data;
foreach (var kv in data) foreach (var kv in data)
{ {
ex.Data["Redis-" + kv.Item1] = kv.Item2; exData["Redis-" + kv.Item1] = kv.Item2;
} }
} }
......
...@@ -738,8 +738,10 @@ private bool PushToBacklog(Message message, bool onlyIfExists) ...@@ -738,8 +738,10 @@ private bool PushToBacklog(Message message, bool onlyIfExists)
private void StartBacklogProcessor() private void StartBacklogProcessor()
{ {
var sched = Multiplexer.SocketManager?.SchedulerPool ?? DedicatedThreadPoolPipeScheduler.Default; var sched = Multiplexer.SocketManager?.SchedulerPool ?? DedicatedThreadPoolPipeScheduler.Default;
_backlogProcessorRequestedTime = Environment.TickCount;
sched.Schedule(s_ProcessBacklog, _weakRefThis); sched.Schedule(s_ProcessBacklog, _weakRefThis);
} }
private volatile int _backlogProcessorRequestedTime;
private static readonly Action<object> s_ProcessBacklog = s => private static readonly Action<object> s_ProcessBacklog = s =>
{ {
...@@ -788,6 +790,8 @@ private void ProcessBacklog() ...@@ -788,6 +790,8 @@ private void ProcessBacklog()
LockToken token = default; LockToken token = default;
try try
{ {
int tryToAcquireTime = Environment.TickCount;
var msToStartWorker = unchecked(tryToAcquireTime - _backlogProcessorRequestedTime);
while(true) while(true)
{ {
// try and get the lock; if unsuccessful, check for termination // try and get the lock; if unsuccessful, check for termination
...@@ -796,6 +800,8 @@ private void ProcessBacklog() ...@@ -796,6 +800,8 @@ private void ProcessBacklog()
lock (_backlog) { if (_backlog.Count == 0) return; } lock (_backlog) { if (_backlog.Count == 0) return; }
} }
_backlogStatus = BacklogStatus.Started; _backlogStatus = BacklogStatus.Started;
int acquiredTime = Environment.TickCount;
var msToGetLock = unchecked(acquiredTime - tryToAcquireTime);
// so now we are the writer; write some things! // so now we are the writer; write some things!
Message message; Message message;
...@@ -816,6 +822,8 @@ private void ProcessBacklog() ...@@ -816,6 +822,8 @@ private void ProcessBacklog()
{ {
_backlogStatus = BacklogStatus.RecordingTimeout; _backlogStatus = BacklogStatus.RecordingTimeout;
var ex = Multiplexer.GetException(WriteResult.TimeoutBeforeWrite, message, ServerEndPoint); var ex = Multiplexer.GetException(WriteResult.TimeoutBeforeWrite, message, ServerEndPoint);
ex.Data["Redis-BacklogStartDelay"] = msToStartWorker;
ex.Data["Redis-BacklogGetLocDelay"] = msToGetLock;
message.SetExceptionAndComplete(ex, this); message.SetExceptionAndComplete(ex, this);
} }
else else
......
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