-
Notifications
You must be signed in to change notification settings - Fork 112
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd double-check for possible deadlocks, but otherwise LGTM (except a few nits).
The request-response cases are:
There are a few scenarios to address:
Peers running new Bitswap should respond immediately in all cases, except for broadcast want-have (send-dont-have = false) when the peer doesn't have the block. Peers running old Bitswap won't respond unless they have the block. In either of these two cases it's possible that
We can mitigate this scenario by ignoring outlier latencies.
It's possible that a peer sends DONT_HAVE and then subsequently sends HAVE / block. To address this I think we should clear out the sent-at time when we receive a response, so that subsequent responses will be ignored for the purpose of latency calculation.
If a peer doesn't respond to want-block, either because it's running old Bitswap or because it's overloaded, the timeout will fire an event that simulates receiving DONT_HAVE. We want to ignore this simulated DONT_HAVE for the purposes of latency tracking, |
With regards to checking for deadlocking, the possible places for slowness / deadlock that I can see are:
@Stebalien any other places we should be thinking about? |
|
||
for _, e := range peerEntries[:sentPeerEntries] { | ||
if e.Cid.Defined() { // Check if want was cancelled in the interim | ||
mq.peerWants.SentAt(e.Cid, now) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if this happens after we receive the block? Is that an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be ok - when the Session receives a block it sends cancel, and cancel removes the want from the sent wantlist. SentAt()
checks that the sent wantlist still contains the want before recording the time a response was received:
func (r *recallWantlist) SentAt(c cid.Cid, at time.Time) {
// The want may have been cancelled in the interim
if _, ok := r.sent.Contains(c); ok {
if _, ok := r.sentAt[c]; !ok {
r.sentAt[c] = at
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds right.
👍
I think we're fine, I just haven't thought through this fully. |
calculate message latency This commit was moved from ipfs/go-bitswap@165b154
Fixes #385