Skip to content

p2p: make dial faster by streamlined discovery process #31678

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

cskiraly
Copy link
Collaborator

@cskiraly cskiraly commented Apr 19, 2025

This PR improves the speed of Disc/v4 and Disc/v5 based discovery. It builds on #31592. To be rebased after merging that PR.

Our dial process is rate-limited, but until now, during startup, our discovery was too slow to serve dial. So the bottleneck was discovery, not the rate limit in dial, resulting in slow ramp-up of outgoing peer count.

This PR making discovery fast enough to serve dial's needs. The rate-limit of dial is still limiting the discovery process, so we are not risking being too aggressive in our discovery.

The PR adds:

  • a pre-fetch buffer to discovery sources, eliminating slowdowns due to timeouts and rate mismatch between the two precesses
  • multiple parallel lookups to make sure enough dial candidates are available all the time

cskiraly added 10 commits April 8, 2025 10:26
Adding an optional name to the dial sources allows better
diagnostics of FairMix and the whole dial process.

Signed-off-by: Csaba Kiraly <[email protected]>
Simple version that does the filtering, but misses pipelining,
waiting for ENRs to be retrieved one-by-one.

Signed-off-by: Csaba Kiraly <[email protected]>
It is not guaranteed that Next will be called until exhaustion
after Close was called. Hence, we need to empty override the
passed channel.

Signed-off-by: Csaba Kiraly <[email protected]>
Signed-off-by: Csaba Kiraly <[email protected]>
BufferIter wraps an iterator and prefetches up to a given
number of nodes from it.

Signed-off-by: Csaba Kiraly <[email protected]>
@cskiraly
Copy link
Collaborator Author

First hour of dial progress before this PR: number of outgoing peers
image

First hour of dial progress after this PR (and #31592): number of outgoing peers
image

@cskiraly
Copy link
Collaborator Author

Discovery traffic before:
image

And after:
image

This PR increases the initial UDP traffic, mostly caused by the pre-fetch buffer. We might dial that down a bit, although I don't think the amount of traffic generated (~70 KB/s) is too much. On the long term, average discovery traffic should be the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant