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
2866adb2
Commit
2866adb2
authored
Jan 18, 2016
by
Marc Gravell
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'mckenzieg1-configurable-socket-mgr-thread-priority'
parents
7b4dc7e1
f6d2e809
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
10 deletions
+27
-10
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
+10
-3
No files found.
StackExchange.Redis/StackExchange/Redis/ConfigurationOptions.cs
View file @
2866adb2
...
@@ -74,7 +74,7 @@ internal static void Unknown(string key)
...
@@ -74,7 +74,7 @@ internal static void Unknown(string key)
internal
const
string
AllowAdmin
=
"allowAdmin"
,
SyncTimeout
=
"syncTimeout"
,
internal
const
string
AllowAdmin
=
"allowAdmin"
,
SyncTimeout
=
"syncTimeout"
,
ServiceName
=
"serviceName"
,
ClientName
=
"name"
,
KeepAlive
=
"keepAlive"
,
ServiceName
=
"serviceName"
,
ClientName
=
"name"
,
KeepAlive
=
"keepAlive"
,
Version
=
"version"
,
ConnectTimeout
=
"connectTimeout"
,
Password
=
"password"
,
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"
,
ConfigChannel
=
"configChannel"
,
AbortOnConnectFail
=
"abortConnect"
,
ResolveDns
=
"resolveDns"
,
ChannelPrefix
=
"channelPrefix"
,
Proxy
=
"proxy"
,
ConnectRetry
=
"connectRetry"
,
ChannelPrefix
=
"channelPrefix"
,
Proxy
=
"proxy"
,
ConnectRetry
=
"connectRetry"
,
ConfigCheckSeconds
=
"configCheckSeconds"
,
ResponseTimeout
=
"responseTimeout"
,
DefaultDatabase
=
"defaultDatabase"
;
ConfigCheckSeconds
=
"configCheckSeconds"
,
ResponseTimeout
=
"responseTimeout"
,
DefaultDatabase
=
"defaultDatabase"
;
...
@@ -83,7 +83,7 @@ internal static void Unknown(string key)
...
@@ -83,7 +83,7 @@ internal static void Unknown(string key)
AllowAdmin
,
SyncTimeout
,
AllowAdmin
,
SyncTimeout
,
ServiceName
,
ClientName
,
KeepAlive
,
ServiceName
,
ClientName
,
KeepAlive
,
Version
,
ConnectTimeout
,
Password
,
Version
,
ConnectTimeout
,
Password
,
TieBreaker
,
WriteBuffer
,
Ssl
,
SslHost
,
TieBreaker
,
WriteBuffer
,
Ssl
,
SslHost
,
HighPrioritySocketThreads
,
ConfigChannel
,
AbortOnConnectFail
,
ResolveDns
,
ConfigChannel
,
AbortOnConnectFail
,
ResolveDns
,
ChannelPrefix
,
Proxy
,
ConnectRetry
,
ChannelPrefix
,
Proxy
,
ConnectRetry
,
ConfigCheckSeconds
,
DefaultDatabase
,
ConfigCheckSeconds
,
DefaultDatabase
,
...
@@ -103,7 +103,7 @@ public static string TryNormalize(string value)
...
@@ -103,7 +103,7 @@ public static string TryNormalize(string value)
private
readonly
EndPointCollection
endpoints
=
new
EndPointCollection
();
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
;
private
string
clientName
,
serviceName
,
password
,
tieBreaker
,
sslHost
,
configChannel
;
...
@@ -217,6 +217,11 @@ public CommandMap CommandMap
...
@@ -217,6 +217,11 @@ public CommandMap CommandMap
/// </summary>
/// </summary>
public
EndPointCollection
EndPoints
{
get
{
return
endpoints
;
}
}
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>
/// <summary>
/// Specifies the time in seconds at which connections should be pinged to ensure validity
/// Specifies the time in seconds at which connections should be pinged to ensure validity
/// </summary>
/// </summary>
...
@@ -329,6 +334,7 @@ public ConfigurationOptions Clone()
...
@@ -329,6 +334,7 @@ public ConfigurationOptions Clone()
writeBuffer
=
writeBuffer
,
writeBuffer
=
writeBuffer
,
ssl
=
ssl
,
ssl
=
ssl
,
sslHost
=
sslHost
,
sslHost
=
sslHost
,
highPrioritySocketThreads
=
highPrioritySocketThreads
,
configChannel
=
configChannel
,
configChannel
=
configChannel
,
abortOnConnectFail
=
abortOnConnectFail
,
abortOnConnectFail
=
abortOnConnectFail
,
resolveDns
=
resolveDns
,
resolveDns
=
resolveDns
,
...
@@ -378,7 +384,8 @@ public override string ToString()
...
@@ -378,7 +384,8 @@ public override string ToString()
Append
(
sb
,
OptionKeys
.
TieBreaker
,
tieBreaker
);
Append
(
sb
,
OptionKeys
.
TieBreaker
,
tieBreaker
);
Append
(
sb
,
OptionKeys
.
WriteBuffer
,
writeBuffer
);
Append
(
sb
,
OptionKeys
.
WriteBuffer
,
writeBuffer
);
Append
(
sb
,
OptionKeys
.
Ssl
,
ssl
);
Append
(
sb
,
OptionKeys
.
Ssl
,
ssl
);
Append
(
sb
,
OptionKeys
.
SslHost
,
sslHost
);
Append
(
sb
,
OptionKeys
.
SslHost
,
sslHost
);
Append
(
sb
,
OptionKeys
.
HighPrioritySocketThreads
,
highPrioritySocketThreads
);
Append
(
sb
,
OptionKeys
.
ConfigChannel
,
configChannel
);
Append
(
sb
,
OptionKeys
.
ConfigChannel
,
configChannel
);
Append
(
sb
,
OptionKeys
.
AbortOnConnectFail
,
abortOnConnectFail
);
Append
(
sb
,
OptionKeys
.
AbortOnConnectFail
,
abortOnConnectFail
);
Append
(
sb
,
OptionKeys
.
ResolveDns
,
resolveDns
);
Append
(
sb
,
OptionKeys
.
ResolveDns
,
resolveDns
);
...
@@ -481,7 +488,7 @@ void Clear()
...
@@ -481,7 +488,7 @@ void Clear()
{
{
clientName
=
serviceName
=
password
=
tieBreaker
=
sslHost
=
configChannel
=
null
;
clientName
=
serviceName
=
password
=
tieBreaker
=
sslHost
=
configChannel
=
null
;
keepAlive
=
syncTimeout
=
connectTimeout
=
writeBuffer
=
connectRetry
=
configCheckSeconds
=
defaultDatabase
=
null
;
keepAlive
=
syncTimeout
=
connectTimeout
=
writeBuffer
=
connectRetry
=
configCheckSeconds
=
defaultDatabase
=
null
;
allowAdmin
=
abortOnConnectFail
=
resolveDns
=
ssl
=
null
;
allowAdmin
=
abortOnConnectFail
=
highPrioritySocketThreads
=
resolveDns
=
ssl
=
null
;
defaultVersion
=
null
;
defaultVersion
=
null
;
endpoints
.
Clear
();
endpoints
.
Clear
();
commandMap
=
null
;
commandMap
=
null
;
...
@@ -579,6 +586,9 @@ private void DoParse(string configuration, bool ignoreUnknown)
...
@@ -579,6 +586,9 @@ private void DoParse(string configuration, bool ignoreUnknown)
case
OptionKeys
.
SslHost
:
case
OptionKeys
.
SslHost
:
SslHost
=
value
;
SslHost
=
value
;
break
;
break
;
case
OptionKeys
.
HighPrioritySocketThreads
:
HighPrioritySocketThreads
=
OptionKeys
.
ParseBoolean
(
key
,
value
);
break
;
case
OptionKeys
.
WriteBuffer
:
case
OptionKeys
.
WriteBuffer
:
WriteBuffer
=
OptionKeys
.
ParseInt32
(
key
,
value
);
WriteBuffer
=
OptionKeys
.
ParseInt32
(
key
,
value
);
break
;
break
;
...
...
StackExchange.Redis/StackExchange/Redis/ConnectionMultiplexer.ReaderWriter.cs
View file @
2866adb2
...
@@ -10,7 +10,7 @@ partial class ConnectionMultiplexer
...
@@ -10,7 +10,7 @@ partial class ConnectionMultiplexer
partial
void
OnCreateReaderWriter
(
ConfigurationOptions
configuration
)
partial
void
OnCreateReaderWriter
(
ConfigurationOptions
configuration
)
{
{
this
.
ownsSocketManager
=
configuration
.
SocketManager
==
null
;
this
.
ownsSocketManager
=
configuration
.
SocketManager
==
null
;
this
.
socketManager
=
configuration
.
SocketManager
??
new
SocketManager
(
ClientName
);
this
.
socketManager
=
configuration
.
SocketManager
??
new
SocketManager
(
ClientName
,
configuration
.
HighPrioritySocketThreads
);
}
}
partial
void
OnCloseReaderWriter
()
partial
void
OnCloseReaderWriter
()
...
...
StackExchange.Redis/StackExchange/Redis/SocketManager.Poll.cs
View file @
2866adb2
...
@@ -377,7 +377,7 @@ private void ReadImpl()
...
@@ -377,7 +377,7 @@ private void ReadImpl()
private
void
StartReader
()
private
void
StartReader
()
{
{
var
thread
=
new
Thread
(
read
,
32
*
1024
);
// don't need a huge stack
var
thread
=
new
Thread
(
read
,
32
*
1024
);
// don't need a huge stack
thread
.
Priority
=
ThreadPriority
.
AboveNormal
;
// time critical
thread
.
Priority
=
useHighPrioritySocketThreads
?
ThreadPriority
.
AboveNormal
:
ThreadPriority
.
Normal
;
thread
.
Name
=
name
+
":Read"
;
thread
.
Name
=
name
+
":Read"
;
thread
.
IsBackground
=
true
;
thread
.
IsBackground
=
true
;
thread
.
Start
(
this
);
thread
.
Start
(
this
);
...
...
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
View file @
2866adb2
...
@@ -116,23 +116,30 @@ internal enum ManagerState
...
@@ -116,23 +116,30 @@ internal enum ManagerState
private
readonly
Queue
<
PhysicalBridge
>
writeQueue
=
new
Queue
<
PhysicalBridge
>();
private
readonly
Queue
<
PhysicalBridge
>
writeQueue
=
new
Queue
<
PhysicalBridge
>();
bool
isDisposed
;
bool
isDisposed
;
private
bool
useHighPrioritySocketThreads
=
true
;
/// <summary>
/// <summary>
/// Creates a new (optionally named) SocketManager instance
/// Creates a new (optionally named) SocketManager instance
/// </summary>
/// </summary>
public
SocketManager
(
string
name
=
null
)
public
SocketManager
(
string
name
=
null
)
:
this
(
name
,
true
)
{
}
/// <summary>
/// Creates a new SocketManager instance
/// </summary>
public
SocketManager
(
string
name
,
bool
useHighPrioritySocketThreads
)
{
{
if
(
string
.
IsNullOrWhiteSpace
(
name
))
name
=
GetType
().
Name
;
if
(
string
.
IsNullOrWhiteSpace
(
name
))
name
=
GetType
().
Name
;
this
.
name
=
name
;
this
.
name
=
name
;
this
.
useHighPrioritySocketThreads
=
useHighPrioritySocketThreads
;
// we need a dedicated writer, because when under heavy ambient load
// we need a dedicated writer, because when under heavy ambient load
// (a busy asp.net site, for example), workers are not reliable enough
// (a busy asp.net site, for example), workers are not reliable enough
#if !CORE_CLR
#if !CORE_CLR
Thread
dedicatedWriter
=
new
Thread
(
writeAllQueues
,
32
*
1024
);
// don't need a huge stack;
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
;
#else
#else
Thread
dedicatedWriter
=
new
Thread
(
writeAllQueues
);
Thread
dedicatedWriter
=
new
Thread
(
writeAllQueues
);
#endif
#endif
dedicatedWriter
.
Name
=
name
+
":Write"
;
dedicatedWriter
.
Name
=
name
+
":Write"
;
dedicatedWriter
.
IsBackground
=
true
;
// should not keep process alive
dedicatedWriter
.
IsBackground
=
true
;
// should not keep process alive
dedicatedWriter
.
Start
(
this
);
// will self-exit when disposed
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