]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Track requests that are preserved across chokings
authorMatt Joiner <anacrolix@gmail.com>
Tue, 12 Oct 2021 02:06:11 +0000 (13:06 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 19 Oct 2021 03:08:56 +0000 (14:08 +1100)
peerconn.go

index e683be5c46f1d876b8ad365bf8a917f408a07e49..009d9a7dbf5b626bdffdb46d5c6262fdca649cd7 100644 (file)
@@ -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: