Remove unused conn piece inclinations
This commit is contained in:
parent
487352fa5b
commit
87a67db680
21
torrent.go
21
torrent.go
|
@ -8,7 +8,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"sort"
|
"sort"
|
||||||
|
@ -139,11 +138,6 @@ type Torrent struct {
|
||||||
activePieceHashes int
|
activePieceHashes int
|
||||||
initialPieceCheckDisabled bool
|
initialPieceCheckDisabled bool
|
||||||
|
|
||||||
// A pool of piece priorities []int for assignment to new connections.
|
|
||||||
// These "inclinations" are used to give connections preference for
|
|
||||||
// different pieces.
|
|
||||||
connPieceInclinationPool sync.Pool
|
|
||||||
|
|
||||||
// Count of each request across active connections.
|
// Count of each request across active connections.
|
||||||
pendingRequests pendingRequests
|
pendingRequests pendingRequests
|
||||||
// Chunks we've written to since the corresponding piece was last checked.
|
// Chunks we've written to since the corresponding piece was last checked.
|
||||||
|
@ -1222,21 +1216,6 @@ func (t *Torrent) openNewConns() (initiated int) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Torrent) getConnPieceInclination() []int {
|
|
||||||
_ret := t.connPieceInclinationPool.Get()
|
|
||||||
if _ret == nil {
|
|
||||||
pieceInclinationsNew.Add(1)
|
|
||||||
return rand.Perm(int(t.numPieces()))
|
|
||||||
}
|
|
||||||
pieceInclinationsReused.Add(1)
|
|
||||||
return *_ret.(*[]int)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *Torrent) putPieceInclination(pi []int) {
|
|
||||||
t.connPieceInclinationPool.Put(&pi)
|
|
||||||
pieceInclinationsPut.Add(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *Torrent) updatePieceCompletion(piece pieceIndex) bool {
|
func (t *Torrent) updatePieceCompletion(piece pieceIndex) bool {
|
||||||
p := t.piece(piece)
|
p := t.piece(piece)
|
||||||
uncached := t.pieceCompleteUncached(piece)
|
uncached := t.pieceCompleteUncached(piece)
|
||||||
|
|
Loading…
Reference in New Issue