-
Notifications
You must be signed in to change notification settings - Fork 591
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
Implement asynchronous methods. #1347
Conversation
5639b7a
to
eeb5a62
Compare
It's awesome seeing these trickle in. Look @davidfowl, we're going full async with Channels and Pipelines :D |
e58ba6c
to
965256a
Compare
@stebet I'd rather not keep a long-running branch. I know there's much more to do for version 7, but I would like to get this into So, if you could give it a quick review, I'll merge it and move on to the next item, which will be reviewing all of the code doc blocks to make sure they are complete and accurate. |
1c720bb
to
2c5c1e1
Compare
I am planning to merge this soon and continue work on version 7 via other PRs to One serious issue is that |
@stebet I figured out why tests were failing when Xunit's parallelization was enabled. There is something incorrect with how The errors I see on the RabbitMQ side are all framing related. "Invalid frame end marker" is a common error, which suggests that the written frame's size is too large, or has corrupt data. The fact that rented arrays can be larger than the requested size is a big hint, so I'm focusing on that. |
Rented arrays should only used with Span or Memory to avoid those issues. Or |
Hi @paulomorgado! Thanks for taking a look. Is that documented anywhere? @stebet here is what I think the problem is - We get a rented array here, for instance - Then, we return the rented array here - But, in the case where the rented array is larger than the requested size, the array being returned won't have the same size, since it has been wrapped and unwrapped by That's my theory, at least. |
@paulomorgado @stebet so much for my theory, this commit does not fix the issue when @paulomorgado we are using Additional theories or suggestions are very welcome! |
It's kind of common sense. ArraySegment is in .NET Framework since version 2,0, but it's not common knowledge. For .NET 6+, I'd go with Span/ReadOnlySpan or Memory/ReadOnlyMemory, because the BCL and the runtime know about it. But they all can wrap slice and warp an array without heap allocations. With spans, can even allocate small array in the stack. https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/lukebakken/async-operations/projects/RabbitMQ.Client/client/impl/Frame.cs#L157-L162 is already using ReadOnlyMemory. I'm a bit concerned about renting arrays in one place and returning in another. One can loose track of those and loose the benefits. You might want to look at MemoryPool. I never used it myself, but you can check wher .NET is using it; https://source.dot.net/#System.Memory/System/Buffers/MemoryPool.cs,790a0fe9f42069bf,references |
If the array is returned and something is still holding on to it, it will be rented again and will be used by more than one "client". That's why you need to keep track of the rented arrays at all times and not let them get out of your sight. |
@paulomorgado thank you for your input. I am not as familiar with .NET / C# as many of the other contributors to this library so I appreciate it. These two statements lead me to the source of the problem:
I added code to the |
9ebe60b
to
5c936ff
Compare
9bb4995
to
8fdffcf
Compare
Thank you @danielmarbach for your review and continued interest in this library. |
You're welcome. I might be able to have a more thorough look at some point. These are only quick observations from scrolling through the changeset |
@danielmarbach I don't plan on releasing version 7 without your and several other key contributors' collective thumbs-up 👍 |
923d31c
to
c4b854b
Compare
I think this PR is too big. If everything is functionally working, it should be merged and issues open for improvements, |
90b72b9
to
7cb74b0
Compare
@paulomorgado yep, I said as much two weeks ago. I am going to give @Gsantomaggio a tour of these changes tomorrow, merge this PR, and move on to other version 7 issues that I have filed. |
Thanks for stopping by @Tornhoof |
7c57728
to
a04ae1e
Compare
Related to: * #1345 * #1308 * #970 * #843 Separate out Unit, Integration and Parallel Integration tests * Creates dedicated test projects for parallel test execution (AsyncIntegration / Integration.csproj) and sequential (SequentialIntegration.csproj). * Ensures that the ThreadPool is set with enough threads. * Ensures that all test connections have their client provided name set. * Fix SequentialTests that require a unique connection name. * Shorten up test names used for connection client provided names * Ensure all async tests are in the AsyncIntegration project. * Convert MassPublish to async/await with multiple publishing connections. * Add MaxParallelThreads in a csproj comment in case we want to try that out * Wait longer when IsRunningInCI * Introduce the RentedMemory struct to encapsulate a rented byte array and its associated ReadOnlyMemory. * Add CreateChannelAsync and modify AsyncIntegration tests to use it. * Add CreateConnectionAsync * Use CreateConnectionAsync in AsyncIntegration * Change the test suite fixes to use ManualResetEventSlim instead of Monitor * Misc refactor to newer language features * SocketFrameHandler CloseAsync * Only increase ThreadPool count for Integration tests * There is no need to expose ClientMemory / RentedMemory * Replace IList with IEnumerable in the API.
a04ae1e
to
dffb2da
Compare
Hi @lukebakken, |
@lukebakken Thats completely fine as it is, have just been using this functionality but if it works with the same performance through single message publish I am happy |
Fixes:
main
#1308Related to:
main
#1308