From: Matt Joiner Date: Tue, 12 Oct 2021 02:06:11 +0000 (+1100) Subject: Track requests that are preserved across chokings X-Git-Tag: v1.34.0^2~41 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=3f3bcab0d8b599a3a1917da50fae273f5bb88c7a;p=btrtrc.git Track requests that are preserved across chokings --- diff --git a/peerconn.go b/peerconn.go index e683be5c..009d9a7d 100644 --- a/peerconn.go +++ b/peerconn.go @@ -1057,12 +1057,20 @@ func (c *PeerConn) mainReadLoop() (err error) { return errors.New("got unchoke but not choked") } c.peerChoking = false + preservedCount := 0 c.actualRequestState.Requests.Iterate(func(x uint32) bool { if !c.peerAllowedFast.Contains(x / c.t.chunksPerRegularPiece()) { + preservedCount++ c.t.pendingRequests.Inc(x) } return true }) + if preservedCount != 0 { + // TODO: Yes this is a debug log but I'm not happy with the state of the logging lib + // right now. + log.Printf("%v requests were preserved while being choked", preservedCount) + torrent.Add("requestsPreservedThroughChoking", int64(preservedCount)) + } c.updateRequests("unchoked") c.updateExpectingChunks() case pp.Interested: