-
-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't starve unverified bytes limit on unrequestable pieces
Solves issue described at #916 (comment).
- Loading branch information
Showing
14 changed files
with
555 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Rough notes on how requests are determined. | ||
|
||
piece ordering cache: | ||
|
||
- pieces are grouped by shared storage capacity and ordered by priority, availability, index and then infohash. | ||
- if a torrent does not have a storage cap, pieces are also filtered by whether requests should currently be made for them. this is because for torrents without a storage cap, there's no need to consider pieces that won't be requested. | ||
|
||
building a list of candidate requests for a peer: | ||
|
||
- pieces are scanned in order of the pre-sorted order for the storage group. | ||
- scanning stops when the cumulative piece length so far exceeds the storage capacity. | ||
- pieces are filtered by whether requests should currently be made for them (hashing, marking, already complete, etc.) | ||
- if requests were added to the consideration list, or the piece was in a partial state, the piece length is added to a cumulative total of unverified bytes. | ||
- if the cumulative total of unverified bytes reaches the configured limit (default 64MiB), piece scanning is halted. | ||
|
||
applying request state: | ||
|
||
- send the appropriate interest message if our interest doesn't match what the peer is seeing | ||
- sort all candidate requests by: | ||
- allowed fast if we're being choked, | ||
- piece priority, | ||
- whether the request is already outstanding to the peer, | ||
- whether the request is not pending from any peer | ||
- if the request is outstanding from a peer: | ||
- how many outstanding requests the existing peer has | ||
- most recently requested | ||
- least available piece |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
package requestStrategy | ||
|
||
type Piece interface { | ||
// Whether requests should be made for this piece. This would be false for cases like the piece | ||
// is currently being hashed, or already complete. | ||
Request() bool | ||
NumPendingChunks() int | ||
// Whether the piece should be counted towards the unverified bytes limit. The intention is to | ||
// prevent pieces being starved from the opportunity to move to the completed state. | ||
CountUnverified() bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This directory contains integration style tests that probably run too long for regular unit testing. It's a separate module to avoid getting run by ./... in the root. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/anacrolix/torrent/tests | ||
|
||
go 1.22.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
go 1.22.0 | ||
|
||
use ( | ||
. | ||
.. | ||
) |
Oops, something went wrong.