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
7dc840bd
Commit
7dc840bd
authored
Apr 02, 2019
by
mgravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
also record the byte count when flushing
parent
087baa90
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
PhysicalBridge.cs
src/StackExchange.Redis/PhysicalBridge.cs
+2
-2
PhysicalConnection.cs
src/StackExchange.Redis/PhysicalConnection.cs
+14
-6
No files found.
src/StackExchange.Redis/PhysicalBridge.cs
View file @
7dc840bd
...
@@ -841,9 +841,9 @@ private void ProcessBacklog()
...
@@ -841,9 +841,9 @@ private void ProcessBacklog()
var
ex
=
Multiplexer
.
GetException
(
WriteResult
.
TimeoutBeforeWrite
,
message
,
ServerEndPoint
);
var
ex
=
Multiplexer
.
GetException
(
WriteResult
.
TimeoutBeforeWrite
,
message
,
ServerEndPoint
);
ex
.
Data
[
"Redis-BacklogStartDelay"
]
=
msToStartWorker
;
ex
.
Data
[
"Redis-BacklogStartDelay"
]
=
msToStartWorker
;
ex
.
Data
[
"Redis-BacklogGetLockDelay"
]
=
msToGetLock
;
ex
.
Data
[
"Redis-BacklogGetLockDelay"
]
=
msToGetLock
;
if
(
_maxWriteTime
>=
0
)
ex
.
Data
[
"Redis-MaxWrite"
]
=
_maxWriteTime
.
ToString
()
+
", "
+
_maxWriteCommand
.
ToString
();
if
(
_maxWriteTime
>=
0
)
ex
.
Data
[
"Redis-MaxWrite"
]
=
_maxWriteTime
.
ToString
()
+
"
ms
, "
+
_maxWriteCommand
.
ToString
();
var
maxFlush
=
physical
?.
MaxFlushTime
??
-
1
;
var
maxFlush
=
physical
?.
MaxFlushTime
??
-
1
;
if
(
maxFlush
>=
0
)
ex
.
Data
[
"Redis-MaxFlush"
]
=
maxFlush
;
if
(
maxFlush
>=
0
)
ex
.
Data
[
"Redis-MaxFlush"
]
=
maxFlush
.
ToString
()
+
"ms, "
+
(
physical
?.
MaxFlushBytes
??
-
1
).
ToString
()
;
message
.
SetExceptionAndComplete
(
ex
,
this
);
message
.
SetExceptionAndComplete
(
ex
,
this
);
}
}
...
...
src/StackExchange.Redis/PhysicalConnection.cs
View file @
7dc840bd
...
@@ -842,12 +842,12 @@ internal static int WriteRaw(Span<byte> span, long value, bool withLengthPrefix
...
@@ -842,12 +842,12 @@ internal static int WriteRaw(Span<byte> span, long value, bool withLengthPrefix
return
WriteCrlf
(
span
,
offset
);
return
WriteCrlf
(
span
,
offset
);
}
}
private
async
ValueTask
<
WriteResult
>
FlushAsync_Awaited
(
PhysicalConnection
connection
,
ValueTask
<
FlushResult
>
flush
,
bool
throwOnFailure
,
int
startFlush
)
private
async
ValueTask
<
WriteResult
>
FlushAsync_Awaited
(
PhysicalConnection
connection
,
ValueTask
<
FlushResult
>
flush
,
bool
throwOnFailure
,
int
startFlush
,
long
flushBytes
)
{
{
try
try
{
{
await
flush
.
ForAwait
();
await
flush
.
ForAwait
();
RecordEndFlush
(
startFlush
);
RecordEndFlush
(
startFlush
,
flushBytes
);
connection
.
_writeStatus
=
WriteStatus
.
Flushed
;
connection
.
_writeStatus
=
WriteStatus
.
Flushed
;
connection
.
UpdateLastWriteTime
();
connection
.
UpdateLastWriteTime
();
return
WriteResult
.
Success
;
return
WriteResult
.
Success
;
...
@@ -884,9 +884,11 @@ internal ValueTask<WriteResult> FlushAsync(bool throwOnFailure)
...
@@ -884,9 +884,11 @@ internal ValueTask<WriteResult> FlushAsync(bool throwOnFailure)
{
{
_writeStatus
=
WriteStatus
.
Flushing
;
_writeStatus
=
WriteStatus
.
Flushing
;
int
startFlush
=
Environment
.
TickCount
;
int
startFlush
=
Environment
.
TickCount
;
long
flushBytes
=
-
1
;
if
(
_ioPipe
is
SocketConnection
sc
)
flushBytes
=
sc
.
GetCounters
().
BytesWaitingToBeSent
;
var
flush
=
tmp
.
FlushAsync
();
var
flush
=
tmp
.
FlushAsync
();
if
(!
flush
.
IsCompletedSuccessfully
)
return
FlushAsync_Awaited
(
this
,
flush
,
throwOnFailure
,
startFlush
);
if
(!
flush
.
IsCompletedSuccessfully
)
return
FlushAsync_Awaited
(
this
,
flush
,
throwOnFailure
,
startFlush
,
flushBytes
);
RecordEndFlush
(
startFlush
);
RecordEndFlush
(
startFlush
,
flushBytes
);
_writeStatus
=
WriteStatus
.
Flushed
;
_writeStatus
=
WriteStatus
.
Flushed
;
UpdateLastWriteTime
();
UpdateLastWriteTime
();
return
new
ValueTask
<
WriteResult
>(
WriteResult
.
Success
);
return
new
ValueTask
<
WriteResult
>(
WriteResult
.
Success
);
...
@@ -897,14 +899,20 @@ internal ValueTask<WriteResult> FlushAsync(bool throwOnFailure)
...
@@ -897,14 +899,20 @@ internal ValueTask<WriteResult> FlushAsync(bool throwOnFailure)
return
new
ValueTask
<
WriteResult
>(
WriteResult
.
WriteFailure
);
return
new
ValueTask
<
WriteResult
>(
WriteResult
.
WriteFailure
);
}
}
}
}
private
void
RecordEndFlush
(
int
start
)
private
void
RecordEndFlush
(
int
start
,
long
bytes
)
{
{
var
end
=
Environment
.
TickCount
;
var
end
=
Environment
.
TickCount
;
int
taken
=
unchecked
(
end
-
start
);
int
taken
=
unchecked
(
end
-
start
);
if
(
taken
>
_maxFlushTime
)
_maxFlushTime
=
taken
;
if
(
taken
>
_maxFlushTime
)
{
_maxFlushTime
=
taken
;
if
(
bytes
>=
0
)
_maxFlushBytes
=
bytes
;
}
}
}
private
volatile
int
_maxFlushTime
=
-
1
;
private
volatile
int
_maxFlushTime
=
-
1
;
private
long
_maxFlushBytes
=
-
1
;
internal
int
MaxFlushTime
=>
_maxFlushTime
;
internal
int
MaxFlushTime
=>
_maxFlushTime
;
internal
long
MaxFlushBytes
=>
_maxFlushBytes
;
private
static
readonly
ReadOnlyMemory
<
byte
>
NullBulkString
=
Encoding
.
ASCII
.
GetBytes
(
"$-1\r\n"
),
EmptyBulkString
=
Encoding
.
ASCII
.
GetBytes
(
"$0\r\n\r\n"
);
private
static
readonly
ReadOnlyMemory
<
byte
>
NullBulkString
=
Encoding
.
ASCII
.
GetBytes
(
"$-1\r\n"
),
EmptyBulkString
=
Encoding
.
ASCII
.
GetBytes
(
"$0\r\n\r\n"
);
...
...
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