-
Notifications
You must be signed in to change notification settings - Fork 592
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
Adding System.IO.Pipelines to replace Channels and Streams (replaces #949) #1199
Conversation
Still ironing out a few things that only seem to manifest in the CI tests (tests all run fine locally), but think they have to do with the fact that synchronous publish now potentially blocks where before it had an unlimited buffer with the UnboundedChannel to write into, so WaitForConfirm tests behave slightly differently with Pipelines. |
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.
Sorry only had like five minutes today. Hopefully I can spend some more time another day
{ | ||
_writeSemaphore.Wait(); | ||
WriteSpan(payload); | ||
_frameHandler.FrameWriter.FlushAsync().AsTask().Wait(); // Sync-over-async, not great, not terrible. All we can do for the sync path. |
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 have not yet used the pipeline stuff very intensively. I was wondering if we could use AsStream
and then use the synchronous stream API here and in the other sync parts?
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.
That actually makes some sense. I'll look into that.
@@ -149,7 +199,7 @@ private void HardProtocolExceptionHandler(HardProtocolException hpe) | |||
{ | |||
var cmd = new ConnectionClose(hpe.ShutdownReason.ReplyCode, hpe.ShutdownReason.ReplyText, 0, 0); | |||
_session0.Transmit(ref cmd); | |||
ClosingLoop(); | |||
await ClosingLoop(); |
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.
ConfigureAwait
|
||
WriteSpan(payload.Span); | ||
await _frameHandler.FrameWriter.FlushAsync().ConfigureAwait(false); | ||
_writeSemaphore.Release(); |
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.
Are you deliberately not doing this in a finally block?
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.
Nope. I'll fix that
Yeah I'm working on cleaning it up a bit. Found some test issues and I'm working on a PR to clean those up first to reduce the noise. |
I reverted #1202 because it makes back and forward-porting impossible unless all maintained branches adopt file-scoped namespaces. |
No probs. I'm a bit busy with work and RL these days. Hoping to submit another PR first that cleans up the unit tests a lot and hopefully makes the more reliable and then clean this PR up after that. |
@stebet I've actually got some time to dedicate to releasing version 7.0 of this library. I'll get the most recent conflicts fixed in this branch, as well as address the most recent review comments. We could discuss the remainder of work here and I could take over. Let me know what you think. |
Hi @stebet, I'm wondering if you have time to read my comment and respond. @bollhals asked about the status of version 7.0 and one major task is completing this PR. As I said, I'm happy to take over work as long as your |
I need to take a little bit closer look at this since I've been out of the loop a bit. I'll take a look in the next days and give you an update. |
Superseded by #1264 |
Proposed Changes
This PR adds System.IO.Pipelines to replace using Channels and Streams to receive and send data to/from the client.
Types of Changes
What types of changes does your code introduce to this project?
Put an
x
in the boxes that applyChecklist
CONTRIBUTING.md
documentFurther Comments
Reasoning
I see Pipelines being a perfect fit here. They make processing buffers a lot easier, reduce overhead when deserializing data and make it a lot easier to implement fully async operations. That's also why they are used for the same purpose in Kestrel (the ASP.NET Core server) Kestrel and StackExchange.Redis.
I also created as-of-yet unused WriteAsync methods for that purpose, which would make it easy to implement fully Async publish methods for example.
Benchmark results (to be added)