mdns: don't perform IO on main task · Issue #2591 · libp2p/rust-libp2p · GitHub
source link: https://github.com/libp2p/rust-libp2p/issues/2591
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
mdns: don't perform IO on main task #2591
Comments
Currently, the
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. |
Contributor
Author
addendum:
|
Contributor
Author
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. |
Contributor
Author
It looks like epoll is being interrupted by registering read interest, which immediately notifies, and waits, upon which this vicious cycle restarts.
|
Contributor
Author
This rabbit hole is deeper than I can follow right now:
|
Contributor
Author
Okay @mxinden I’m pretty sure I know how it happens, but I’m not sure how to fix it:
If I remove |
Contributor
Author
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. |
changed the title
mDNS poll loop
protocols/mDNS: Poll UDP socket in separate task
added difficulty:moderate
getting-started Issues that can be tackled if you don't know the internals of libp2p very well
labels
added priority:important The changes needed are critical for libp2p, or are blocking another project getting-started Issues that can be tackled if you don't know the internals of libp2p very well
and removed getting-started Issues that can be tackled if you don't know the internals of libp2p very well
labels
Tagging this as important because it performs IO on the main task that all |
removed the getting-started Issues that can be tackled if you don't know the internals of libp2p very well label
changed the title
protocols/mDNS: Poll UDP socket in separate task
mdns: don't perform IO on main task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
No milestone
Successfully merging a pull request may close this issue.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK