Skip to content

Commit

Permalink
add iter count
Browse files Browse the repository at this point in the history
  • Loading branch information
mh0lt committed May 26, 2024
1 parent 97b879a commit 7a364ae
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions requesting.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ func (p *Peer) getDesiredRequestStateDebug() (desired desiredRequestState) {
}

callCount := 0
iterCount := 0

// Caller-provided allocation for roaring bitmap iteration.
var it typedRoaring.Iterator[RequestIndex]
requestStrategy.GetRequestablePieces(
Expand All @@ -261,6 +263,7 @@ func (p *Peer) getDesiredRequestStateDebug() (desired desiredRequestState) {
requestHeap.pieceStates[pieceIndex] = pieceExtra
allowedFast := p.peerAllowedFast.Contains(pieceIndex)
t.iterUndirtiedRequestIndexesInPiece(&it, pieceIndex, func(r requestStrategy.RequestIndex) {
iterCount++
if !allowedFast {
// We must signal interest to request this. TODO: We could set interested if the
// peers pieces (minus the allowed fast set) overlap with our missing pieces if
Expand All @@ -285,10 +288,11 @@ func (p *Peer) getDesiredRequestStateDebug() (desired desiredRequestState) {
},
)

p.logger.Levelf(log.Debug, "desired %indexes=%d states=%d calls=%d", len(t.requestIndexes), len(t.requestPieceStates), callCount)

t.assertPendingRequests()
desired.Requests = requestHeap

p.logger.Levelf(log.Debug, "desired req=%d indexes=%d states=%d calls=%d iter=%d", len(requestHeap.requestIndexes), len(t.requestIndexes), len(t.requestPieceStates), callCount, iterCount)

return
}

Expand Down

0 comments on commit 7a364ae

Please sign in to comment.