When the routing table is empty, `Run` would fail but _not_ close the
process (leaking some query goroutines). This patch fixes this in multiple
places by:
1. Not starting queries with no peers.
2. Failing queries with no peers earlier.
When a peer is found, add its addr to the peerstore, just like the addresses for closer peers are added. In particular this is helpful for followup queries by the DHT user.
This patch introduces an adaptive dial queue that spawns a dynamically sized
set of goroutines to preemptively stage dials for later handoff to the DHT
protocol for RPC. It identifies backpressure on both ends (dial consumers and
dial producers), and takes compensating action by adjusting the worker pool.
We start with `DialQueueMinParallelism` number of workers (6), and scale up
and down based on demand and supply of dialled peers.
The following events trigger scaling:
- we scale up when we can't immediately return a successful dial to a new
consumer.
- we scale down when we've been idle for a while waiting for new dial
attempts.
- we scale down when we complete a dial and realise nobody was waiting for it.
Dialler throttling (e.g. FD limit exceeded) is a concern, as we can easily
spin up more workers to compensate, and end up adding fuel to the fire. Since
we have no deterministic way to detect this for now, we hard-limit concurrency
to `DialQueueMaxParallelism` (20).
Both, dht.go and dht_bootstrap.go duplicate the package documentation.
The whole block had been moved to doc.go
Also query.go provides documentation for query package but now it
belongs to dht package, so it's been removed.
Without this, one of the workers may hang when trying to re-grab the rate-limit
after dialing. I believe this may be what's causing some of our DHT requests to
stall (evidence: massive goroutine buildup on the gateways).
First, we use Alpha instead of K as the number of peers we grab from the
routing table (as per the kademlia paper).
Second, we don't use a size limited set for the 'GetClosestPeers' query.
We're going to process more than K peers before we find the K closest
peers.
Third, Change GetClosestPeers to actually return the K Closest peers,
not a hodge podge of peers that it found on the way to finding the
closest peers.
* Update golog in go-ipfs
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
* Update go-libp2p for go-log
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
* Update go-libp2p-secio for go-log
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
* Update go-libp2p-crypto for go-log
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
* Update go-libp2p-peer for go-log
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
* Import peersore, it wasn't imported
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
* Update peerstore
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
* Update peer
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
* Update secio
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
* Update go-libp2p
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
For the rest of the packages in util, move them to thirdparty
and update the references. util is gone!
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>