-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Arising out of this: https://github.com/filecoin-project/lassie/pull/321/files#r1243072856
Discussed today in a call and agreed that we should roughly align it to the other retrievers.
This block:
lassie/pkg/retriever/bitswapretriever.go
Lines 143 to 164 in 46c970b
bytesWrittenCb := func(bytesWritten uint64) { | |
// record first byte received | |
if totalWritten.Load() == 0 { | |
br.events(events.FirstByte(br.clock.Now(), br.request.RetrievalID, phaseStartTime, bitswapCandidate, br.clock.Since(phaseStartTime))) | |
} | |
totalWritten.Add(bytesWritten) | |
blockCount.Add(1) | |
// reset the timer | |
if bytesWritten > 0 && lastBytesReceivedTimer != nil { | |
lastBytesReceivedTimer.Reset(br.cfg.BlockTimeout) | |
} | |
} | |
// setup providers for this retrieval | |
hasCandidates, nextCandidates, err := ayncCandidates.Next(ctx) | |
if !hasCandidates || err != nil { | |
cancel() | |
// we never received any candidates, so we give up on bitswap retrieval | |
return nil, nil | |
} | |
br.events(events.Started(br.clock.Now(), br.request.RetrievalID, phaseStartTime, types.RetrievalPhase, bitswapCandidate, multicodec.TransportBitswap)) |
The duration in FirstByte is taken from phaseStartTime
(startTime
in #321) which is at the top of RetrieveFromAsyncCandidates
which is prior to collecting the first batch of candidates. The other retrievers take this duration from the beginning of asking the candidate for the data. But for Bitswap it's before we even collect candidates.
Likely solution
The bytesWrittenCb
should be moved down lower and a new start
clock time recorded before it. That new start
time can be used by both the Started event and the FirstByte duration calculation.