From 87f6cdc1e96fdd846bb9c55cfd5176a17373d4b6 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 11 Sep 2023 10:10:13 +1000 Subject: [PATCH] Fix request heap pop bug Missed in the changed interface from 613470861e67fdb11c9661930f3490cba0aa19b2. Caused very poor performance. Thanks to @AskAlexSharov for raising the flag in https://github.com/anacrolix/torrent/issues/859#issuecomment-1706059960. --- requesting.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requesting.go b/requesting.go index 46796bd2..8b9db971 100644 --- a/requesting.go +++ b/requesting.go @@ -265,7 +265,7 @@ func (p *Peer) applyRequestState(next desiredRequestState) { originalRequestCount, p.needRequestUpdate)) } for requestHeap.Len() != 0 && maxRequests(current.Requests.GetCardinality()+current.Cancelled.GetCardinality()) < p.nominalMaxRequests() { - req := requestHeap.Pop() + req := heap.Pop(requestHeap) existing := t.requestingPeer(req) if existing != nil && existing != p { // Don't steal from the poor.