-
Notifications
You must be signed in to change notification settings - Fork 941
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
mdns: don't perform IO on main task #2591
Comments
addendum:
|
okay, here’s the really weird part: with this patch to
I then tried generating a netlink message by adding an IP address, which first did the right and expected thing and then spun a few dozen loops before going back to sleep again. So this looks like a race condition that when triggered leads to endless wakeups of the swarm. |
It looks like epoll is being interrupted by registering read interest, which immediately notifies, and waits, upon which this vicious cycle restarts.
|
This rabbit hole is deeper than I can follow right now:
|
Okay @mxinden I’m pretty sure I know how it happens, but I’m not sure how to fix it:
If I remove |
Sleeping on it, I have doubts on the current design of libp2p-mdns: I don’t think the UDP ports should be polled every time something unrelated happens in the rest of the Swarm, and I also don’t think that the rest of the Swarm should be polled every time something happens on those UDP ports. |
In the previous version of the code the readable and writable functions were running constantly causing high CPU consumption constantly when using tokio as runtime. Fix libp2p#2591 Fix libp2p#2675
In the previous version of the code the readable and writable functions were running constantly causing high CPU consumption constantly when using tokio as runtime. Fix libp2p#2591 Fix libp2p#2675
Tagging this as important because it performs IO on the main task that all |
Currently, the
mdns::Behaviour
polls theInterfaceState
on the main task, seerust-libp2p/protocols/mdns/src/behaviour.rs
Lines 290 to 306 in d1d358c
InterfaceState
in turn performs IO as part of this:rust-libp2p/protocols/mdns/src/behaviour/iface.rs
Lines 206 to 210 in d1d358c
We should not be doing any form of IO on the main behaviour task because it reduces latency in the dispatch and handling of events distributed to the various behaviours.
To fix this, we should spawn a separate task per runtime and communicate with it via a channels.
The text was updated successfully, but these errors were encountered: