-
Notifications
You must be signed in to change notification settings - Fork 151
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
IConnection.Request performs slower than manual request/reply #299
Comments
Thanks for raising this, and really appreciate the info! We do some mapping of subject names to requests - a map that could grow quickly but I wouldn't expect this much from the GC. This tells us we need to take a pass through and see if we can re-use some objects to prevent the GC churn. |
Adding a timeout involves the creation of a |
Unless I'm missing something I believe CancellationTokenSource per request can be avoided. As long as the token source has not been cancelled it can be reused as many times as necessary. It's only when the token source has been 'tripped' that a new one has to be created. |
The CTS performs the timeout (via |
@CrossBound I've just provided a small fix but even with this in you will get GC clean/work unless usage of |
I don't believe the serialization is impacting this much because otherwise I'd have the same problem when doing the manual request / reply. I understand your comment (and @watfordgnf 's above), however, I guess my question is: Is it necessary to use CancellationTokenSource.CancelAfter as the method of timing out or is there a better (more efficient) way to accomplish the same thing. Notice in my code I have no such call and it works much more efficiently. |
I will continue to look into improving the request op. Just wanted to fix the memory issue first. Will look into the use of tokens, sources etc. |
This should be resolved by #339 and is now in pre-release: https://www.nuget.org/packages/NATS.Client/0.10.1-pre1 If you test it we'd certainly like to hear of your results. |
Fixed, never closed, closing now. |
So based on the comment here nats-io/nats.net#297 (comment) I tried using the request api. Heres some interesting results. If I use RequestAsync like this:
I run about ~3,300+ msgs/sec with RTT of 1.12 ms /ea P99. My VS Analysis tools however show some interesting CPU and GC data.
However, if I change my code to look like this
my performance improves significantly.... notice the number of messages per second as well as the GC collections and CPU data.
The text was updated successfully, but these errors were encountered: