Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Closest peers query is not efficient #86

Open
vasco-santos opened this issue Mar 4, 2019 · 4 comments
Open

Closest peers query is not efficient #86

vasco-santos opened this issue Mar 4, 2019 · 4 comments
Labels
exp/wizard Extensive knowledge (implications, ramifications) required P1 High: Likely tackled by core team if no one steps up status/ready Ready to be worked

Comments

@vasco-santos
Copy link
Member

By default, dht.getClosestPeers is crawling all the network to find the closestPeers, which takes a long time and hits heavily the CPU when we have a large number of peers.

This was also a problem observed in #85 , as this took a lot of time and returned a large set of peers, which ended up failing the dht.put for lack of response of several peers. Moreover, queries also have an impact on random-walk performance.

We need a deterministic way of ending this network query, as well as to refactor closestPeers and put to be more fault tolerant.

We should stream the query and have an abort logic that would allow us to stop the query at a certain point. In addition, we need to have a smarter connection manager to full enable this.

cc @jacobheun @dirkmc

@vasco-santos vasco-santos changed the title Closest peers query Closest peers query is not efficient Mar 4, 2019
@vasco-santos vasco-santos added status/ready Ready to be worked exp/wizard Extensive knowledge (implications, ramifications) required P1 High: Likely tackled by core team if no one steps up labels Mar 4, 2019
@vasco-santos
Copy link
Member Author

We should consider: libp2p/go-libp2p-kad-dht#237

@dirkmc
Copy link
Contributor

dirkmc commented Mar 4, 2019

SGTM 👍

I'm currently implementing streaming as part of the async/await refactor

Should we simply end the query when the timeout occurs? I've also implemented this behaviour in the refactor.

@vasco-santos
Copy link
Member Author

We currently do not have a timeout for put / getClosestPeers, but it can be a possibility.

In addition, I think we should define a minimum number of peers (from the closest) to put, instead of needing by default to put all of them (I am against this, but while we don't have a proper logic to identify if a peer has a dht running, we should maybe do that).

Also, if we can define in the closestPeers an option for the numberOfPeers / minNumberOfPeers, it can also help. However, I am not sure what should be the ideal values to use.

Ideally, we should not need to do this kind of stuff, and if we do, we should open issues for guaranteeing that when we are in a better position regarding performance and smarter connection manager, we can aim to go back to "normal"

@jacobheun
Copy link
Contributor

but while we don't have a proper logic to identify if a peer has a dht running, we should maybe do that

We're working on support for this for the Gossipsub implementation, it should hopefully be added to the switch soon (mostly just testing and interop testing left). This would enable us to check peerInfo.protocols for the dht protocol, so we could prevent actions to those peers who are missing it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
exp/wizard Extensive knowledge (implications, ramifications) required P1 High: Likely tackled by core team if no one steps up status/ready Ready to be worked
Projects
None yet
Development

No branches or pull requests

3 participants