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
reuse runtime instead of spawning new ones in new Thread #27
Comments
Thank you for your interest! Sharing my thoughts below, please let me know yours:) This assumes that the Runtime is needed in every single use case, but this is not guaranteed. Regarding double blocking: since it works inside a regular (non-async) function, it has to block since it has nothing else to do while fetching the list of mirrors to test. The threading approach allows for parallel progress tracking in the main thread. |
I'm not sure I understand why this is. I was assuming that every target has to fetch their mirrorlist or test their servers with the asynchronous calls on
In that case, how about using blocking calls to
I wasn't sure about that. Thanks for clearing that up! |
I've left the explicit use of Regarding "way cheaper", I haven't profiled this, but I bet this cannot be noticed in a networking application like this. |
I see, thanks for clearing this up!
Seems like this is what you call "premature optimization" on my end, oops. You are right, it's definitely not needed, there's barely anything to gain, if anything at all. |
main
spawns a new thread to fetch the correct mirrorsrate-mirrors/src/main.rs
Lines 103 to 109 in dad9c23
This thread then spawns a Runtime to block on an async function
rate-mirrors/src/targets/archlinux.rs
Line 39 in dad9c23
rate-mirrors/src/targets/archlinux.rs
Lines 42 to 43 in dad9c23
Would it make sense to create a general Runtime instead to reuse in the functions that fetch mirrors instead? Or is this done by design?
Reusing the runtime would, for instance, make sense in
fetch_arch_mirrors
as the Runtime currently blocks twice there, negating the pros of using tokio there in the first place.The text was updated successfully, but these errors were encountered: