-
Notifications
You must be signed in to change notification settings - Fork 12
Make ads::client::Client sync
#39
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
Conversation
|
Hi, thanks for the PR! The problem is that when communicate can be called concurrently, replies are not guaranteed to end up where they need to go - if two threads start a request at the same time, the reader thread will just send both replies to the channel, and each calling thread will get one, but they might be the wrong ones. It's certainly possible to make it work, but so far I haven't thought about what the minimal/best change to the architecture would look like to achieve that. |
|
I wrapped all of the client network IO in a mutexed block. I can see this getting more efficient if you wanted to adopt a coroutine-oriented api with primitives from |
|
@birkenfeld I ended up refactoring the background worker logic a bit so that the client can dispatch requests concurrently and receive their responses asynchronously |
2608f1a to
060d3c2
Compare
|
Hey @birkenfeld just a friendly ping :) |
|
Thanks! This isn't forgotten, I just need a quiet time for review... Fortunately some leave is coming up during which I might have time for that. |
|
No problem, like I said before, feel free to suggest/make changes! |
|
I also had a productive conversation with bhf support about routing in general, and now I'm fairly certain that the |
|
Hey @birkenfeld, any updates? |
|
Thanks for the ping, should be able to review now! |
|
Let me know what you want to do about the dropped test and inconsistent packet handling. I think I managed to take care of everything else, but please correct me if I'm wrong |
|
Thanks for the changes, looks very nice, just a few points to finish up! |
|
That should be everything, you're good to rerun CI |
|
Great, thanks! For interest, did you run some benchmarks to see if the changes make a noticeable difference in performance in a single-threaded use case? |
|
I just finished up a test project, I can confirm that the current changes actually increases performance. I'm seeing a 10-15% speedup with the current changes.
These numbers stayed pretty stable across multiple runs. The linux results were collected in WSL, so I'm pretty sure that virtio overhead is to blame for the unexpected slowdown. |
|
Thank you! So correct me if I'm wrong, the more reliable benchmark (outside WSL) is not showing a speedup? (Although 14% doesn't worry me too much) Do you have the benchmarking code ready? I'd like to run them on my Linux setup too. Since we're doing a lot of locking, it might be worth looking at parking_lot mutexes too. |
|
I made the benchmarking code a bit more rigorous, and most of the perf differences are negligible. I pushed the benching code to The server emu code is cobbled together from the bhf ADS .net samples with some minor code changes of my own. Lmk if you have trouble running them |
Both Windows and Linux showed a perf improvement using the new code, I was just surprised that the Windows tests were running faster than the Linux tests, since that's usually the other way around. |
|
I just benched against a build using |
So the 1400/1600 numbers are switched in the table?
Oh ok, that will be hard for me to run on Linux I think. But in any case, I think this is good to go, I can try to do some benching/optimizing later if I get the fancies :D
Thanks for verifying this! |
|
Regarding the merge, are you fine with squashing? |
Yes, you'll have to forgive my intermittent blindness 🥲
Squashing is fine with me! |
|
I just pushed linux-specific bug fixes to the benching branches. You'll be able to use .net 9, as well, so no worries with trying to figure out how to get the preview sdk set up and working. |
|
Thanks for the patience and getting this over the finish line! :D |
This is the minimum diff required to make
ads::client::Clientsync. I considered making a specialErrorvariant specific to locks, but I'm pretty sure that there's no way application code to induce a poisoned lock, and any poisons that come from standard library panics should definitely result in an aborted application.Feel free to modify.