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
473fbd91
Commit
473fbd91
authored
Aug 10, 2015
by
David McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added configuration option "HighPrioritySocketThreads" (default 'true' = current behavior)
parent
83a046eb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
9 deletions
+21
-9
ConfigurationOptions.cs
...xchange.Redis/StackExchange/Redis/ConfigurationOptions.cs
+15
-5
ConnectionMultiplexer.ReaderWriter.cs
...StackExchange/Redis/ConnectionMultiplexer.ReaderWriter.cs
+1
-1
SocketManager.Poll.cs
...kExchange.Redis/StackExchange/Redis/SocketManager.Poll.cs
+1
-1
SocketManager.cs
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
+4
-2
No files found.
StackExchange.Redis/StackExchange/Redis/ConfigurationOptions.cs
View file @
473fbd91
...
...
@@ -71,7 +71,7 @@ internal static void Unknown(string key)
internal
const
string
AllowAdmin
=
"allowAdmin"
,
SyncTimeout
=
"syncTimeout"
,
ServiceName
=
"serviceName"
,
ClientName
=
"name"
,
KeepAlive
=
"keepAlive"
,
Version
=
"version"
,
ConnectTimeout
=
"connectTimeout"
,
Password
=
"password"
,
TieBreaker
=
"tiebreaker"
,
WriteBuffer
=
"writeBuffer"
,
Ssl
=
"ssl"
,
SslHost
=
"sslHost"
,
TieBreaker
=
"tiebreaker"
,
WriteBuffer
=
"writeBuffer"
,
Ssl
=
"ssl"
,
SslHost
=
"sslHost"
,
HighPrioritySocketThreads
=
"highPriorityThreads"
,
ConfigChannel
=
"configChannel"
,
AbortOnConnectFail
=
"abortConnect"
,
ResolveDns
=
"resolveDns"
,
ChannelPrefix
=
"channelPrefix"
,
Proxy
=
"proxy"
,
ConnectRetry
=
"connectRetry"
,
ConfigCheckSeconds
=
"configCheckSeconds"
,
ResponseTimeout
=
"responseTimeout"
,
DefaultDatabase
=
"defaultDatabase"
;
...
...
@@ -80,7 +80,7 @@ internal static void Unknown(string key)
AllowAdmin
,
SyncTimeout
,
ServiceName
,
ClientName
,
KeepAlive
,
Version
,
ConnectTimeout
,
Password
,
TieBreaker
,
WriteBuffer
,
Ssl
,
SslHost
,
TieBreaker
,
WriteBuffer
,
Ssl
,
SslHost
,
HighPrioritySocketThreads
,
ConfigChannel
,
AbortOnConnectFail
,
ResolveDns
,
ChannelPrefix
,
Proxy
,
ConnectRetry
,
ConfigCheckSeconds
,
DefaultDatabase
,
...
...
@@ -100,7 +100,7 @@ public static string TryNormalize(string value)
private
readonly
EndPointCollection
endpoints
=
new
EndPointCollection
();
private
bool
?
allowAdmin
,
abortOnConnectFail
,
resolveDns
,
ssl
;
private
bool
?
allowAdmin
,
abortOnConnectFail
,
highPrioritySocketThreads
,
resolveDns
,
ssl
;
private
string
clientName
,
serviceName
,
password
,
tieBreaker
,
sslHost
,
configChannel
;
...
...
@@ -210,6 +210,11 @@ public CommandMap CommandMap
/// </summary>
public
EndPointCollection
EndPoints
{
get
{
return
endpoints
;
}
}
/// <summary>
/// Use ThreadPriority.AboveNormal for SocketManager reader and writer threads (true by default). If false, ThreadPriority.Normal will be used.
/// </summary>
public
bool
HighPrioritySocketThreads
{
get
{
return
highPrioritySocketThreads
??
true
;
}
set
{
highPrioritySocketThreads
=
value
;
}
}
/// <summary>
/// Specifies the time in seconds at which connections should be pinged to ensure validity
/// </summary>
...
...
@@ -322,6 +327,7 @@ public ConfigurationOptions Clone()
writeBuffer
=
writeBuffer
,
ssl
=
ssl
,
sslHost
=
sslHost
,
highPrioritySocketThreads
=
highPrioritySocketThreads
,
configChannel
=
configChannel
,
abortOnConnectFail
=
abortOnConnectFail
,
resolveDns
=
resolveDns
,
...
...
@@ -372,6 +378,7 @@ public override string ToString()
Append
(
sb
,
OptionKeys
.
WriteBuffer
,
writeBuffer
);
Append
(
sb
,
OptionKeys
.
Ssl
,
ssl
);
Append
(
sb
,
OptionKeys
.
SslHost
,
sslHost
);
Append
(
sb
,
OptionKeys
.
HighPrioritySocketThreads
,
highPrioritySocketThreads
);
Append
(
sb
,
OptionKeys
.
ConfigChannel
,
configChannel
);
Append
(
sb
,
OptionKeys
.
AbortOnConnectFail
,
abortOnConnectFail
);
Append
(
sb
,
OptionKeys
.
ResolveDns
,
resolveDns
);
...
...
@@ -471,7 +478,7 @@ void Clear()
{
clientName
=
serviceName
=
password
=
tieBreaker
=
sslHost
=
configChannel
=
null
;
keepAlive
=
syncTimeout
=
connectTimeout
=
writeBuffer
=
connectRetry
=
configCheckSeconds
=
defaultDatabase
=
null
;
allowAdmin
=
abortOnConnectFail
=
resolveDns
=
ssl
=
null
;
allowAdmin
=
abortOnConnectFail
=
highPrioritySocketThreads
=
resolveDns
=
ssl
=
null
;
defaultVersion
=
null
;
endpoints
.
Clear
();
commandMap
=
null
;
...
...
@@ -567,6 +574,9 @@ private void DoParse(string configuration, bool ignoreUnknown)
case
OptionKeys
.
SslHost
:
SslHost
=
value
;
break
;
case
OptionKeys
.
HighPrioritySocketThreads
:
HighPrioritySocketThreads
=
OptionKeys
.
ParseBoolean
(
key
,
value
);
break
;
case
OptionKeys
.
WriteBuffer
:
WriteBuffer
=
OptionKeys
.
ParseInt32
(
key
,
value
);
break
;
...
...
StackExchange.Redis/StackExchange/Redis/ConnectionMultiplexer.ReaderWriter.cs
View file @
473fbd91
...
...
@@ -10,7 +10,7 @@ partial class ConnectionMultiplexer
partial
void
OnCreateReaderWriter
(
ConfigurationOptions
configuration
)
{
this
.
ownsSocketManager
=
configuration
.
SocketManager
==
null
;
this
.
socketManager
=
configuration
.
SocketManager
??
new
SocketManager
(
ClientName
);
this
.
socketManager
=
configuration
.
SocketManager
??
new
SocketManager
(
ClientName
,
configuration
.
HighPrioritySocketThreads
);
}
partial
void
OnCloseReaderWriter
()
...
...
StackExchange.Redis/StackExchange/Redis/SocketManager.Poll.cs
View file @
473fbd91
...
...
@@ -400,7 +400,7 @@ private void StartReader()
var
thread
=
new
Thread
(
read
,
32
*
1024
);
// don't need a huge stack
thread
.
Name
=
name
+
":Read"
;
thread
.
IsBackground
=
true
;
thread
.
Priority
=
ThreadPriority
.
AboveNormal
;
// time critical
thread
.
Priority
=
useHighPrioritySocketThreads
?
ThreadPriority
.
AboveNormal
:
ThreadPriority
.
Normal
;
thread
.
Start
(
this
);
}
[
StructLayout
(
LayoutKind
.
Sequential
)]
...
...
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
View file @
473fbd91
...
...
@@ -80,19 +80,21 @@ public sealed partial class SocketManager : IDisposable
private
readonly
Queue
<
PhysicalBridge
>
writeQueue
=
new
Queue
<
PhysicalBridge
>();
bool
isDisposed
;
private
bool
useHighPrioritySocketThreads
=
true
;
/// <summary>
/// Creates a new (optionally named) SocketManager instance
/// </summary>
public
SocketManager
(
string
name
=
null
)
public
SocketManager
(
string
name
=
null
,
bool
useHighPrioritySocketThreads
=
true
)
{
if
(
string
.
IsNullOrWhiteSpace
(
name
))
name
=
GetType
().
Name
;
this
.
name
=
name
;
this
.
useHighPrioritySocketThreads
=
useHighPrioritySocketThreads
;
// we need a dedicated writer, because when under heavy ambient load
// (a busy asp.net site, for example), workers are not reliable enough
Thread
dedicatedWriter
=
new
Thread
(
writeAllQueues
,
32
*
1024
);
// don't need a huge stack;
dedicatedWriter
.
Priority
=
ThreadPriority
.
AboveNormal
;
// time critical
dedicatedWriter
.
Priority
=
useHighPrioritySocketThreads
?
ThreadPriority
.
AboveNormal
:
ThreadPriority
.
Normal
;
dedicatedWriter
.
Name
=
name
+
":Write"
;
dedicatedWriter
.
IsBackground
=
true
;
// should not keep process alive
dedicatedWriter
.
Start
(
this
);
// will self-exit when disposed
...
...
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