Skip to content

Conversation

@ajtowns
Copy link
Contributor

@ajtowns ajtowns commented Feb 28, 2019

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%.

@fanquake fanquake added the P2P label Feb 28, 2019
@gmaxwell
Copy link
Contributor

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 ?)

@ajtowns
Copy link
Contributor Author

ajtowns commented Feb 28, 2019

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 vFastConnect which contains a bool/address pair. The bool is true if the address is ready to be tried, and false if it's finished with and ready to be replaced. If the bool is true, the address's group is added to setConnected when picking new addresses to try, which should prevent the same netgroup from being tried multiple times.

(I was trying for something not too intrusive, so haven't looked at async/non-blocking connect())

@DrahtBot
Copy link
Contributor

DrahtBot commented Apr 5, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, 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.

@fanquake
Copy link
Member

@naumenkogs Did you want to have a look here and Concept ACK or NACK ?

@naumenkogs
Copy link
Contributor

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?
Just --fast-bootstrap for now, and then we might merge it with something else (for example, with the default memory allocation for utreexo cache or whatnot) so that at the end we have high-memory mode? Let me know if this discussion happened before and there is a consensus that parameters like this is generally a bad idea :)

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.
@ajtowns ajtowns force-pushed the 201902-trytoavoiddns branch from cdce57f to 62686dc Compare September 23, 2019 10:36
@ajtowns
Copy link
Contributor Author

ajtowns commented Sep 23, 2019

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.

@ajtowns
Copy link
Contributor Author

ajtowns commented Sep 17, 2020

Dropping this for now

@ajtowns ajtowns closed this Sep 17, 2020
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Querying DNS seeds too frequently

5 participants