Skip to content
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

Better RT refresh & mantainence #465

Closed
wants to merge 5 commits into from
Closed

Better RT refresh & mantainence #465

wants to merge 5 commits into from

Conversation

aarshkshah1992
Copy link
Contributor

@aarshkshah1992 aarshkshah1992 commented Feb 27, 2020

@Stebalien
For #283, #434 & libp2p/go-libp2p#779.

Corresponding Routing Table PR:
libp2p/go-libp2p-kbucket#54

@aarshkshah1992 aarshkshah1992 changed the base branch from master to stabilize February 27, 2020 17:51
@aarshkshah1992 aarshkshah1992 changed the title [WIP] Better RT refresh & mantainence Better RT refresh & mantainence Feb 28, 2020
@aarshkshah1992
Copy link
Contributor Author

ping @Stebalien

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM, nothing critical/blocking.

@aschmahmann could I get a second review on this? It'll probably need to be rebased.

dht.go Outdated Show resolved Hide resolved
dht.go Outdated Show resolved Hide resolved
dht_bootstrap.go Outdated Show resolved Hide resolved
// startSelfLookup starts a go-routine that listens for requests to trigger a self walk on a dedicated channel
// and then sends the error status back on the error channel sent along with the request.
// if multiple callers "simultaneously" ask for a self walk, it performs ONLY one self walk and sends the same error status to all of them.
func (dht *IpfsDHT) startSelfLookup() error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revisiting this, I'm not sure if we need something quite this complicated. We can probably get away with just calling selfWalk from within both the refresh function and the "address changed" loop.

(although we'll need to do it asynchronously inside the "address changed" loop)

Note: this code looks fine. I'm just not sure if the complexity is warranted.

@Stebalien Stebalien requested a review from willscott March 5, 2020 06:33
@@ -17,7 +19,7 @@ var DefaultBootstrapPeers []multiaddr.Multiaddr

// Minimum number of peers in the routing table. If we drop below this and we
// see a new peer, we trigger a bootstrap round.
var minRTRefreshThreshold = 4
var minRTRefreshThreshold = 20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like a high minimum for triggering new bootstraps. was this for testing, or intentional?

Copy link
Contributor Author

@aarshkshah1992 aarshkshah1992 Mar 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional. The current interval for a refresh is too much (1 hour) & we want to be more proactive in doing refreshes when needed rather than doing them to often without needing to do them. But really, we can always tune these params if we run into problems later.

@@ -710,9 +750,9 @@ func (dht *IpfsDHT) handleProtocolChanges(proc goprocess.Process) {
// TODO: discuss how to handle this case
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this also trigger an update?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@willscott Great spot ! It will after this code in Adin's PR goes in.

dht.go Outdated
evts := []interface{}{&event.EvtPeerIdentificationCompleted{}, &event.EvtPeerIdentificationFailed{}}
dht.subscriptions.evtPeerIdentification, err = h.EventBus().Subscribe(evts, eventbus.BufSize(256))
if err != nil {
logger.Errorf("dht not subscribed to peer identification events; things will fail; err: %s", err)
}

dht.subscriptions.everPeerAddressChanged, err = h.EventBus().Subscribe(&event.EvtLocalAddressesUpdated{}, eventbus.BufSize(256))
if err != nil {
logger.Errorf("dht not sybscribed to peer address changed event; err=%s ", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.Errorf("dht not sybscribed to peer address changed event; err=%s ", err)
logger.Errorf("dht not subscribed to peer address changed event; err=%s ", err)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@willscott Oh that's just how we spell it down here. It's a very us thing.

dht_bootstrap.go Outdated
}

// Batch multiple refresh requests if they're all waiting at the same time.
collectWaiting:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this loop of collecting all waiting channels be broken out into a separate function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done.

dht_bootstrap.go Outdated
return
}
switch evt.(type) {
case event.EvtLocalAddressesUpdated:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we only care about one type here, can we do this as
if _, ok := evt.(event.EvtLocalAddressesUpdated); ok { ... }

Copy link
Contributor Author

@aarshkshah1992 aarshkshah1992 Mar 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done.

@aarshkshah1992
Copy link
Contributor Author

Status Update @Stebalien @aschmahmann @willscott

I have addressed review comments that I've gotten till now. Will rebase this on the cypress branch once Adin's work on switching between client/server goes in and ask you guys to take one final look.

@aarshkshah1992
Copy link
Contributor Author

aarshkshah1992 commented Mar 6, 2020

Closing in favour of #482.

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.

3 participants