summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
f21aeed)
This reverts commit
9eb80abc29498ecc8ba2b174457b46ca75296dec.
Via email I received a report of excessive memory use: Memory use with a slice is proportional to the total size of all torrents loaded into the Client, which can be very large.
if c.t.requestingPeer(r) != c {
panic("only one peer should have a given request at a time")
}
if c.t.requestingPeer(r) != c {
panic("only one peer should have a given request at a time")
}
- c.t.requestState[r] = requestState{}
+ delete(c.t.requestState, r)
// c.t.iterPeers(func(p *Peer) {
// if p.isLowOnRequests() {
// p.updateRequests("Peer.deleteRequest")
// c.t.iterPeers(func(p *Peer) {
// if p.isLowOnRequests() {
// p.updateRequests("Peer.deleteRequest")
connsWithAllPieces map[*Peer]struct{}
connsWithAllPieces map[*Peer]struct{}
- requestState []requestState
+ requestState map[RequestIndex]requestState
// Chunks we've written to since the corresponding piece was last checked.
dirtyChunks typedRoaring.Bitmap[RequestIndex]
// Chunks we've written to since the corresponding piece was last checked.
dirtyChunks typedRoaring.Bitmap[RequestIndex]
func (t *Torrent) onSetInfo() {
t.pieceRequestOrder = rand.Perm(t.numPieces())
t.initPieceRequestOrder()
func (t *Torrent) onSetInfo() {
t.pieceRequestOrder = rand.Perm(t.numPieces())
t.initPieceRequestOrder()
- MakeSliceWithLength(&t.requestState, t.numChunks())
MakeSliceWithLength(&t.requestPieceStates, t.numPieces())
for i := range t.pieces {
p := &t.pieces[i]
MakeSliceWithLength(&t.requestPieceStates, t.numPieces())
for i := range t.pieces {
p := &t.pieces[i]
t.cl.event.Broadcast()
close(t.gotMetainfoC)
t.updateWantPeersEvent()
t.cl.event.Broadcast()
close(t.gotMetainfoC)
t.updateWantPeersEvent()
+ t.requestState = make(map[RequestIndex]requestState)
t.tryCreateMorePieceHashers()
t.iterPeers(func(p *Peer) {
p.onGotInfo(t.info)
t.tryCreateMorePieceHashers()
t.iterPeers(func(p *Peer) {
p.onGotInfo(t.info)
}
// TODO: This is a check that an old invariant holds. It can be removed after some testing.
//delete(t.pendingRequests, r)
}
// TODO: This is a check that an old invariant holds. It can be removed after some testing.
//delete(t.pendingRequests, r)
- var zeroRequestState requestState
- if t.requestState[r] != zeroRequestState {
+ if _, ok := t.requestState[r]; ok {
panic("expected request state to be gone")
}
return p
panic("expected request state to be gone")
}
return p