Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
5892e528
Commit
5892e528
authored
Jul 13, 2015
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explicitly track busy worker count
parent
ce3785ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
ConnectionMultiplexer.cs
...change.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
+13
-11
No files found.
StackExchange.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
View file @
5892e528
...
...
@@ -560,14 +560,15 @@ private static bool WaitAllIgnoreErrors(Task[] tasks, int timeout)
}
return
false
;
}
private
void
LogLockedWithThreadPoolStats
(
TextWriter
log
,
string
message
)
private
void
LogLockedWithThreadPoolStats
(
TextWriter
log
,
string
message
,
out
int
busyWorkerCount
)
{
busyWorkerCount
=
0
;
if
(
log
!=
null
)
{
var
sb
=
new
StringBuilder
();
sb
.
Append
(
message
);
string
iocp
,
worker
;
GetThreadPoolStats
(
out
iocp
,
out
worker
);
busyWorkerCount
=
GetThreadPoolStats
(
out
iocp
,
out
worker
);
sb
.
Append
(
", IOCP: "
).
Append
(
iocp
).
Append
(
", WORKER: "
).
Append
(
worker
);
LogLocked
(
log
,
sb
.
ToString
());
}
...
...
@@ -598,8 +599,8 @@ private async Task<bool> WaitAllIgnoreErrorsAsync(Task[] tasks, int timeoutMilli
}
var
watch
=
Stopwatch
.
StartNew
();
LogLockedWithThreadPoolStats
(
log
,
"Awaiting task completion"
);
int
busyWorkerCount
;
LogLockedWithThreadPoolStats
(
log
,
"Awaiting task completion"
,
out
busyWorkerCount
);
try
{
...
...
@@ -607,7 +608,7 @@ private async Task<bool> WaitAllIgnoreErrorsAsync(Task[] tasks, int timeoutMilli
var
remaining
=
timeoutMilliseconds
-
checked
((
int
)
watch
.
ElapsedMilliseconds
);
if
(
remaining
<=
0
)
{
LogLockedWithThreadPoolStats
(
log
,
"Timeout before awaiting for tasks"
);
LogLockedWithThreadPoolStats
(
log
,
"Timeout before awaiting for tasks"
,
out
busyWorkerCount
);
return
false
;
}
...
...
@@ -619,7 +620,7 @@ private async Task<bool> WaitAllIgnoreErrorsAsync(Task[] tasks, int timeoutMilli
var
any
=
Task
.
WhenAny
(
allTasks
,
Task
.
Delay
(
remaining
)).
ObserveErrors
();
#endif
bool
all
=
await
any
.
ForAwait
()
==
allTasks
;
LogLockedWithThreadPoolStats
(
log
,
all
?
"All tasks completed cleanly"
:
"Not all tasks completed cleanly"
);
LogLockedWithThreadPoolStats
(
log
,
all
?
"All tasks completed cleanly"
:
"Not all tasks completed cleanly"
,
out
busyWorkerCount
);
return
all
;
}
catch
...
...
@@ -635,7 +636,7 @@ private async Task<bool> WaitAllIgnoreErrorsAsync(Task[] tasks, int timeoutMilli
var
remaining
=
timeoutMilliseconds
-
checked
((
int
)
watch
.
ElapsedMilliseconds
);
if
(
remaining
<=
0
)
{
LogLockedWithThreadPoolStats
(
log
,
"Timeout awaiting tasks"
);
LogLockedWithThreadPoolStats
(
log
,
"Timeout awaiting tasks"
,
out
busyWorkerCount
);
return
false
;
}
try
...
...
@@ -651,7 +652,7 @@ private async Task<bool> WaitAllIgnoreErrorsAsync(Task[] tasks, int timeoutMilli
{
}
}
}
LogLockedWithThreadPoolStats
(
log
,
"Finished awaiting tasks"
);
LogLockedWithThreadPoolStats
(
log
,
"Finished awaiting tasks"
,
out
busyWorkerCount
);
return
false
;
}
...
...
@@ -1888,7 +1889,7 @@ internal T ExecuteSyncImpl<T>(Message message, ResultProcessor<T> processor, Ser
};
int
queue
=
server
.
GetOutstandingCount
(
message
.
Command
,
out
inst
,
out
qu
,
out
qs
,
out
qc
,
out
wr
,
out
wq
,
out
@in
,
out
ar
);
GetThreadPoolStats
(
out
iocp
,
out
worker
);
int
busyWorkerCount
=
GetThreadPoolStats
(
out
iocp
,
out
worker
);
add
(
"Instantaneous"
,
"inst"
,
inst
.
ToString
());
#if !__MonoCS__
add
(
"Manager-State"
,
"mgr"
,
mgrState
.
ToString
());
...
...
@@ -1905,7 +1906,7 @@ internal T ExecuteSyncImpl<T>(Message message, ResultProcessor<T> processor, Ser
add
(
"ThreadPool-IO-Completion"
,
"IOCP"
,
iocp
);
add
(
"ThreadPool-Workers"
,
"WORKER"
,
worker
);
data
.
Add
(
Tuple
.
Create
(
"Busy-Workers"
,
busyWorkerCount
.
ToString
()));
errMessage
=
sb
.
ToString
();
if
(
stormLogThreshold
>=
0
&&
queue
>=
stormLogThreshold
&&
Interlocked
.
CompareExchange
(
ref
haveStormLog
,
1
,
0
)
==
0
)
{
...
...
@@ -1935,7 +1936,7 @@ internal T ExecuteSyncImpl<T>(Message message, ResultProcessor<T> processor, Ser
return
val
;
}
}
private
static
void
GetThreadPoolStats
(
out
string
iocp
,
out
string
worker
)
private
static
int
GetThreadPoolStats
(
out
string
iocp
,
out
string
worker
)
{
//BusyThreads = TP.GetMaxThreads() –TP.GetAVailable();
//If BusyThreads >= TP.GetMinThreads(), then threadpool growth throttling is possible.
...
...
@@ -1954,6 +1955,7 @@ private static void GetThreadPoolStats(out string iocp, out string worker)
iocp
=
string
.
Format
(
"(Busy={0},Free={1},Min={2},Max={3})"
,
busyIoThreads
,
freeIoThreads
,
minIoThreads
,
maxIoThreads
);
worker
=
string
.
Format
(
"(Busy={0},Free={1},Min={2},Max={3})"
,
busyWorkerThreads
,
freeWorkerThreads
,
minWorkerThreads
,
maxWorkerThreads
);
return
busyWorkerThreads
;
}
/// <summary>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment