-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[H/3] Wait for WritesClosed
and Dispose
as fire-and-forget
#104035
Conversation
Related to #102571, let's run this on http benchmarks. |
I just ran the gRPC benchmarks on this:
The base line 966,263 RPS is not as bad as reported in #77139 (which was meager ~300k RPS). But this PR with 3,850,558 RPS is at the same numbers as before the issue was reported ~3.8m RPS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
/azp run runtime-libraries stress-http |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
@@ -88,7 +88,14 @@ public void Dispose() | |||
{ | |||
_disposed = true; | |||
AbortStream(); | |||
_stream.Dispose(); | |||
if (_stream.WritesClosed.IsCompleted) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is _stream.WritesClosed.IsCompleted
expected to be true most of the time for basic GET/POST requests (when we're not doing bidirectional streaming)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run runtime-libraries stress-http |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if CI is green.
if (endStream) | ||
{ | ||
await _stream.WritesClosed.ConfigureAwait(false); | ||
} | ||
|
||
await _stream.FlushAsync(cancellationToken).ConfigureAwait(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels odd that we're flushing after we've ensured that writes are complete. If the flush is a no-op can we delete it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll switch the order.
/azp run runtime-libraries stress-http |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run runtime-libraries stress-http |
Azure Pipelines successfully started running 1 pipeline(s). |
Alternative to #104032. Solves the perf problem for waiting
Dispose
(with sync-over-async) by waiting onQuicStream.WritesClosed
at the end of content writing together with doingQuicStream
disposal as fire-and-forget in case the writes are already closed (avoiding potential data-loss).cc @liveans
Fixes #77139