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
ccc1e1a3
Commit
ccc1e1a3
authored
Mar 17, 2016
by
Marc Gravell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #363 from JonCole/master
Capture client system CPU percentage in timeout error messages
parents
59a7cb68
dc201866
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
ConnectionMultiplexer.cs
...change.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
+12
-0
DebuggingAids.cs
StackExchange.Redis/StackExchange/Redis/DebuggingAids.cs
+48
-0
No files found.
StackExchange.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
View file @
ccc1e1a3
...
...
@@ -1968,6 +1968,8 @@ 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
()));
add
(
"Local-CPU"
,
"Local-CPU"
,
GetSystemCpuPercent
());
#endif
errMessage
=
sb
.
ToString
();
if
(
stormLogThreshold
>=
0
&&
queue
>=
stormLogThreshold
&&
Interlocked
.
CompareExchange
(
ref
haveStormLog
,
1
,
0
)
==
0
)
...
...
@@ -2000,6 +2002,16 @@ internal T ExecuteSyncImpl<T>(Message message, ResultProcessor<T> processor, Ser
}
#if !CORE_CLR
private
static
string
GetSystemCpuPercent
()
{
float
systemCPU
;
if
(
PerfCounterHelper
.
TryGetSystemCPU
(
out
systemCPU
))
{
return
Math
.
Round
(
systemCPU
,
2
)
+
"%"
;
}
return
"unavailable"
;
}
private
static
int
GetThreadPoolStats
(
out
string
iocp
,
out
string
worker
)
{
//BusyThreads = TP.GetMaxThreads() –TP.GetAVailable();
...
...
StackExchange.Redis/StackExchange/Redis/DebuggingAids.cs
View file @
ccc1e1a3
using
System
;
using
System.Diagnostics
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
@@ -297,6 +298,53 @@ public enum CompletionType
Async
=
2
}
#if !CORE_CLR
internal
static
class
PerfCounterHelper
{
static
object
staticLock
=
new
object
();
static
volatile
PerformanceCounter
_cpu
;
static
volatile
bool
_disabled
;
public
static
bool
TryGetSystemCPU
(
out
float
value
)
{
value
=
-
1
;
try
{
if
(!
_disabled
&&
_cpu
==
null
)
{
lock
(
staticLock
)
{
if
(
_cpu
==
null
)
{
_cpu
=
new
PerformanceCounter
(
"Processor"
,
"% Processor Time"
,
"_Total"
);
// First call always returns 0, so get that out of the way.
_cpu
.
NextValue
();
}
}
}
}
catch
(
UnauthorizedAccessException
)
{
// Some environments don't allow access to Performance Counters, so stop trying.
_disabled
=
true
;
}
catch
(
Exception
)
{
// this shouldn't happen, but just being safe...
}
if
(
_cpu
!=
null
)
{
value
=
_cpu
.
NextValue
();
return
true
;
}
return
false
;
}
}
internal
class
CompletionTypeHelper
{
...
...
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