-
Notifications
You must be signed in to change notification settings - Fork 38.7k
p2p: Speed up initial connection to p2p network #15502
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
|
I'd love to be making more connect attempts to distinct hosts at once, but I'm not super eager to add more threads: each one implies quite a few megabytes of additional memory usage (both res and virt, from the per thread stacks and the malloc pools) which are problematic on low memory systems. Perhaps it's ultimately worth it, but have you looked into just making the connects() non-blocking and handling them asynchronously? Startup isn't the only time this should be useful, it would also be nice to reconnect quickly when we've lost our peers due to a network interruption. Aside, I don't see what in this is preventing it from trying the same netgroup multiple times concurrently, which should probably be avoided. (Perhaps by just passing in a filter to addrman to tell it to return only hosts where netgroup%threads==thread ?) |
It's putting the addresses being tried in (I was trying for something not too intrusive, so haven't looked at async/non-blocking connect()) |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
@naumenkogs Did you want to have a look here and Concept ACK or NACK ? |
|
I think the trade-off is straightforward, as Greg points out: bootstrap speed vs. memory usage. It certainly would be more attractive if we make non-blocking connections instead, but I don't have an idea of how much effort that would require. If we decide to stick to the current proposal, perhaps we can pass this as an argument? |
Also check every 25s whether we've got enough active outbounds that DNS seeds aren't worth querying, and exit the thread early if so.
cdce57f to
62686dc
Compare
|
I think #16939 is enough to stop the privacy leak here, but would still be nice to connect to nodes more quickly. I think it might not be too hard to do a select() loop just for non-proxied (and non-tor) connections, so I'll give that a go. |
|
Dropping this for now |
This patch creates four threads for connecting to the P2P network on startup. This allows more attempts based on peers.dat before the timeout for connecting to two peers hits and the DNS seeds are queried for more peers. Once an initial quorum of outbound peers are connected, these extra threads end, and long term behaviour continues unchanged.
Fixes #15434
Marked as draft, looking for concept acks. Second patch just dumps some statistics on how successful connections are (successful = connection established, not a VERACK actually received). I get 20%-30% on initial startup; after running a while seems to be down to ~17%.