Skip to content

Commit

Permalink
Merge pull request #9 from erigontech/increase_webseed_parallelization
Browse files Browse the repository at this point in the history
Reduce broadcast noise and fix small file processing
  • Loading branch information
mh0lt authored May 25, 2024
2 parents ea7c91a + 07a6952 commit f6c82ba
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions webseed-peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,25 @@ func (ws *webseedPeer) requester(i int) {
pendingRequests = 16
}

ws.maxRequesters = pendingRequests
ws.requesterCond.Broadcast()
if ws.maxRequesters != pendingRequests {
ws.maxRequesters = pendingRequests
ws.requesterCond.Broadcast()
}
}

}

if !restart {
if !(ws.peer.t.dataDownloadDisallowed.Bool() || ws.peer.t.Complete.Bool()) {
if ws.updateRequestor == nil {
ws.updateRequestor = time.AfterFunc(webpeerUnchokeTimerDuration, func() { requestUpdate(ws) })
timerDuration := webpeerUnchokeTimerDuration

// Don't wait for small files
if ws.peer.t.NumPieces() == 1 && ws.peer.requestState.Requests.GetCardinality() == 0 {
timerDuration = 0
}

ws.updateRequestor = time.AfterFunc(timerDuration, func() { requestUpdate(ws) })
}
}

Expand Down Expand Up @@ -230,12 +239,17 @@ func requestUpdate(ws *webseedPeer) {

ws.updateRequestor = nil

ws.peer.logger.Levelf(log.Debug, "requestUpdate %d (p=%d,d=%d,n=%d) active(c=%d,m=%d,w=%d) complete(%d/%d)",
ws.processedRequests, int(ws.peer.requestState.Requests.GetCardinality()), len(ws.peer.getDesiredRequestState().Requests.requestIndexes),
ws.nominalMaxRequests(), len(ws.activeRequests), ws.maxActiveRequests, ws.waiting, ws.peer.t.numPiecesCompleted(), ws.peer.t.NumPieces())

if !ws.peer.closed.IsSet() {
numPieces := uint64(ws.peer.t.NumPieces())
numCompleted := ws.peer.t._completedPieces.GetCardinality()

if numCompleted < numPieces {
if ws.peer.isLowOnRequests() && time.Since(ws.peer.lastRequestUpdate) > webpeerUnchokeTimerDuration {
// Don't wait for small files
if ws.peer.isLowOnRequests() && (numPieces == 1 || time.Since(ws.peer.lastRequestUpdate) > webpeerUnchokeTimerDuration) {
// if the number of incomplete pieces is less than five adjust this peers
// lastUsefulChunkReceived to ensure that it can steal from non web peers
// this is to help ensure completion - we may want to add a head call
Expand Down

0 comments on commit f6c82ba

Please sign in to comment.