-
Notifications
You must be signed in to change notification settings - Fork 52
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
JetStream publish performance #450
Comments
not sure if this is a good test. v1 doesn't actually seem to be publishing as fast:
|
@safayatborhan, where are you seeing the performance in your real application? Could you elaborate on your use case a little more? In your test application v1 Publish() is looking faster but overall performance doesn't show that, so a little confused about that tbh. (Thank you for the example repo btw 💯 a lot easier for me to validate the issues) |
Hi @mtmk, In actual scenario, we are trying to publish around 10000 messages/sec. Each message size is around 1kb. For processing each message the legacy NATS client (stan) took around 1.77E-05. But as it is out of life, we migrated to Jetstream and here is the data for v1 and v2 client of Jetstream: |
I see the same magnitude of difference too. Also, starting the v1 app seems to be instant, however the v2 app takes several seconds to start..... Edit : I believe I was testing this in the VS IDE and whilst V1 is faster there, V2 is faster outside |
I'm afraid your metric above doesn't make sense to me as meaningful comparison. I'm seeing very different results on different machines with different number of concurrent tasks. But, when tuned (for example number of tasks), overall I'm not seeing hardly any difference unfortunately. I assume you're interested in throughput and I suggest to have a look at this issue: Having said that, I think there are improvements we can make in the request-reply pattern (which I will start investigating soon #453) but I don't think it would make a material difference to how many messages you can send per second. edit: I can reproduce similar results as above, when run on a single core cloud machine. but when run on my desktop machine with multiple cores, results are very different:
when compiled AOT:
(this is running code from your repo https://github.com/safayatborhan/Memory.Test with no changes) |
@safayatborhan I also cannot recreate the latency that you are seeing. I forked your What OS and hardware are you getting those results on? |
Also @safayatborhan if you can please confirm which version of the .NET Runtime your Net6 tests were run against, especially if it is not 6.0.6 or newer (just to be safe, this was something AkkaDotNet encountered, but was fixed in 6.0.6 and newer) Agreed that hardware could also make a huge difference here (and may still enlighten on opportunities.) I certainly have guesses as to what could happen with a low core count/etc but am working on being better about my tangents. :) |
@caleblloyd and @to11mtm , This is surprising to me that you are getting different result. |
|
@caleblloyd |
@safayatborhan did you make any progress? it'd be good to get on the same page on this 😅 |
If it's any help, there are significant differences between running the tests inside the Visual Studio IDE vs outside, even on Release x64 code. Inside the IDE V1 seems to always win, outside of the IDE, V2 wins. E.g. On my 24 Core desktop... Windows 11 10 Tasks Release - Inside of IDE V1 Avg: 0.014, Min: 0.003, Max: 0.058, Max Threads: 18 Release - Outside of IDE V1 Avg: 0.006, Min: 0.001, Max: 0.067, Max Threads: 19 50 Tasks Release - Inside of IDE V1 Avg: 0.074, Min: 0.004, Max: 0.184, Max Threads: 37 Release - Outside of IDE V1 Avg: 0.024, Min: 0.002, Max: 0.114, Max Threads: 24 |
thanks @darkwatchuk it defo helps 💯 so the figures are ms per message? lower is better? I know I'm jumping the gun and going on a tangent maybe (sorry @to11mtm 😅) but I'm also not convinced the method of measuring performance as suggested above isn't producing helpful or practical results unfortunately. what are your thoughts and if you agree how should we measure it? |
Yes, lower is better. This was running the code from the provided repo. As @safayatborhan is running Windows, it could be that he's running and testing from Visual Studio maybe and starts accidentally in debugging mode with even with the release build. Just guessing. But certainly from what I can see it produces drastically different results and can easily give the wrong impression. Clearly the VS debugging overhead for V2 is higher for V1. |
@darkwatchuk |
Thanks so much, @darkwatchuk, for getting to the bottom of this. This highlighted that there is a performance improvement we can make for request-reply. However, it probably won't help in this scenario, but nevertheless, it did help highlight that. I will close this issue now. Thanks. |
Observed behavior
I have a dotnet 6 application running on nats.net. If I migrate to nats.net.v2, the performance is degrading drastically. Here is the code I am running with nats.net.v2 library:
Sample output:
Here is the same code I am running with nats.net library:
Sample output:
Expected behavior
The latest library should be as fast as how it was before.
Server and client version
Nats.net 2.1.2
Host environment
No response
Steps to reproduce
Repo link, if want to reproduce.
The text was updated successfully, but these errors were encountered: