2
0
mirror of synced 2025-02-23 22:28:11 +00:00

2881 Commits

Author SHA1 Message Date
Matt Joiner
33883c04e4 Filter next requests application for peer state changes 2021-09-20 14:16:55 +10:00
Matt Joiner
a8c7516246 Add NOTES 2021-09-20 12:31:44 +10:00
Matt Joiner
d90c41c534 Add choking/allowed fast checks to Peer.shouldRequest 2021-09-18 19:00:21 +10:00
Matt Joiner
cfb23e271f Export request_strategy.GetRequestablePieces 2021-09-18 18:57:50 +10:00
Matt Joiner
72eb52bb8e goimports doing its thing 2021-09-18 18:54:54 +10:00
Matt Joiner
900f36f1a9 Add some tests verifying request map ordering 2021-09-18 13:50:55 +10:00
Matt Joiner
7d8d5b0cfc Update anacrolix/args for bool Flag fix 2021-09-18 13:23:36 +10:00
Matt Joiner
c6fb0535d4 requesting: Remove some obsoleted condition checks
These shouldn't be necessary since peers were pruned for the ability to allocate chunks to the current piece.
2021-09-18 12:53:22 +10:00
Matt Joiner
dd52a1440f request_strategy.Peer.canRequestPiece performance: Reorder conditions 2021-09-18 12:53:22 +10:00
YenForYang
7b19e81fc6
bencode: get type of big.Int without creating instance (#651)
Nope, it doesn't really matter. But anyway, see c084706c22/cryptobyte/asn1.go (L267)
2021-09-18 12:44:47 +10:00
YenForYang
ed3b3ee5ca
bencode: simplify getting marshalerType and unmarshalerType (#652) 2021-09-18 12:43:53 +10:00
YenForYang
d43769dc15
bencode: Simplify (*Decoder).parseListInterface() (#656)
Preserve as much type as possible (it'll be converted to an `interface{}` anyway, but we can return `[]interface{}` instead of `{}interface` here).
2021-09-18 12:42:20 +10:00
YenForYang
f3a9ea5aa9
Prevent allocation when checking interface (#649) 2021-09-18 12:36:25 +10:00
YenForYang
c740cde71b
metainfo: Remove reflection dependency for Piece.Hash() (#661)
`copy`  will copy exactly `HashSize` bytes here.
2021-09-18 11:35:21 +10:00
YenForYang
35ad29dccc
lockWithDeferreds: inlineable Unlock() (#603) 2021-09-17 13:08:00 +10:00
Matt Joiner
b757b62cf4 requesting: Filter peers that can't be allocated chunks 2021-09-16 10:47:27 +10:00
Matt Joiner
aa32c94844 Rejig waits between doRequests 2021-09-16 00:12:58 +10:00
Matt Joiner
a4697497aa Performance improvements in piece requesting 2021-09-16 00:12:24 +10:00
Matt Joiner
2b443d695b Change torrent capacity to not return a pointer
It's an unnecessary complication for a storage implementer.
2021-09-15 23:33:17 +10:00
Matt Joiner
72b0fee1eb Simplify PIece.iterUndirtiedChunks 2021-09-15 23:33:17 +10:00
Matt Joiner
377eabd7b4 Pre-allocate request strategy pieces 2021-09-15 23:33:17 +10:00
Matt Joiner
baddf0e528 cmd/torrent: Use anacrolix/args and merge several other cmds in as subcommands 2021-09-15 10:54:14 +10:00
YenForYang
ebb7160599
Inlineable (*Torrent).Seeding() (#626) 2021-09-15 10:28:14 +10:00
YenForYang
e105d8b57a
Inlineable (*Torrent).SetDisplayName() (#625) 2021-09-15 10:27:52 +10:00
YenForYang
542970b961
Inlineable (*Torrent).PieceState() (#621) 2021-09-15 10:14:28 +10:00
YenForYang
d00ba917c0
Inlineable (*Torrent).AddPeers() (#622) 2021-09-15 10:14:07 +10:00
YenForYang
a0fe0a087d
Inlineable DownloadPieces() and CancelPieces() (#623) 2021-09-15 10:13:46 +10:00
YenForYang
29638d9e5d
Create default constructor for Client (#567)
Allow for certain values to always be properly initialized on construction -- namely the maps for now. I'm currently working on a change that requires a baseline constructor; this change would make the use of `chansync.BroadcastCond` and `chansync.SetOnce` obsolete -- i.e. one can have channel members without worrying about proper initialization/destruction of a `chan struct{}`.

As for why `makeClient` returns a value instead of a pointer: returning a value gives us more options -- you can always take a pointer from a value later on cheaply, and have things moved to the heap if they weren't already. The same can't be said about getting a value back from a pointer. GC also could potentially have less work to do. Plus I personally find ownership to be an important concept (semi-borrowed from rust) -- use of values make ownership clear.
2021-09-14 23:01:20 +10:00
YenForYang
e80b989f8e
Clarify maximum value of "metadata_size" (#609) 2021-09-14 22:36:19 +10:00
YenForYang
57b4e78b0f
Inlineable (*File).BytesCompleted() (#612) 2021-09-14 22:11:35 +10:00
YenForYang
be8b7b7d35
Optimize LoopbackListenHost() (#615) 2021-09-14 21:54:37 +10:00
YenForYang
f6b024e157
Inlineable (*reader).SetReadAhead and (*reader).Close (#594)
Small fixes that prevent inlining of public functions
2021-09-14 14:05:37 +10:00
YenForYang
a8db640c62
Drop bradfitz/iter dependency (#605)
* Drop bradfitz/iter dependency

`range iter.N` looks nice and doesn't allocate, but unfortunately using a `range` expression blocks a function from being inlined wherever it's used (for now). It's not that we need inlining in all cases, but I do think a C-style for loop looks just as nice and is probably clearer to the majority. There also aren't any clear disadvantages to changing (unless you just happen to dislike the look of C)

* Update misc_test.go

* Update rlreader_test.go

* Update torrent_test.go

* Update bench_test.go

* Update client_test.go

* Update iplist_test.go

* Update mse_test.go

* Update peerconn_test.go

* Update peerconn.go

* Update order_test.go

* Update decoder_test.go

* Update main.go

* Update bench-piece-mark-complete.go

* Update main.go

* Update torrent.go

* Update iplist_test.go

* Update main.go
2021-09-14 13:46:50 +10:00
YenForYang
2203b3bcdf
Cheaper byte to string conversion (#602)
Revamped https://github.com/anacrolix/torrent/pull/587
2021-09-14 10:41:04 +10:00
YenForYang
5332d3e9d4
Inlineable reader.Seek and no-lock return for bad whence (#577)
* Inlineable reader.Seek and no-lock return for bad whence

Couldn't find an elegant way to early exit on bad whence. Using a closure could reduce code duplication slightly, but it's overkill for only 3 cases.

Note that returning 0 on an invalid whence is the behavior of `strings.Reader` and `bytes.Reader`.

* Update reader.go
2021-09-13 22:52:58 +10:00
YenForYang
134eea8418
Fix usages of eachListener() and make inlineable (#599) 2021-09-13 21:35:51 +10:00
YenForYang
52e8c82999
Inlineable methods to access File piecePriority (#601) 2021-09-13 21:17:54 +10:00
YenForYang
5c440e8929
Simplify (*Torrent).gotMetainfo (#581) 2021-09-13 11:41:11 +10:00
YenForYang
1bb6724020
Remove xerrors dependency (#600)
* Remove xerrors dependency

* Update main.go
2021-09-13 11:38:08 +10:00
YenForYang
3b4d4a64ff
Reorder fields to reduce padding in reader (#597)
Reorder some of the fields to reduce the size of `reader`. Not much of a change -- original size was 104 bytes, with changes (moving bool's to the end) the size is 96 bytes. There's also the whole cache-friendly bit -- I tried reordering fields to help here, but I doubt it makes much of a difference.

Some other notes: `sync.Locker` is a 16 byte field. I suggest changing this to something like `*sync.RWMutex` or `*lockWithDeferreds`. This would not only reduce size but would allow access to `RLock`/`RUnlock`.
`pieceRange` could also be shrunk to 8 bytes, but I feel like I'm probably asking for too much lol.
2021-09-13 11:36:35 +10:00
YenForYang
4691b0b8d1
Update ReadCloser interface check to ReadSeekCloser (#595) 2021-09-12 14:14:07 +10:00
Matt Joiner
a9cbb644c5
Fix http announce of infohash containing ' ' bytes (#591)
Fixes https://github.com/anacrolix/torrent/issues/534.
2021-09-12 14:11:59 +10:00
Matt Joiner
79ad5e4676 Don't call Client onClose handlers until torrent storages are closed 2021-09-11 11:39:33 +10:00
Matt Joiner
7378d50a3c Fix Torrent.Drop to wait for storage close without client lock 2021-09-11 11:39:33 +10:00
YenForYang
d957502528
Avoid allocating memory when checking interface (#588)
Not a big deal, but there isn't a need to allocate an object to check that `*Node` satisfies `bencode.Unmarshaler`.
2021-09-11 08:26:43 +10:00
Matt Joiner
6c9a7fec39 Optimize peersForPieces allocations for make and sorting 2021-09-10 23:07:10 +10:00
Matt Joiner
c4445fd201 Optimize requesting peerId Uintptr allocation 2021-09-10 23:07:10 +10:00
Matt Joiner
e9193968a3 Disable ensureValidSortedPeersForPieceRequests
Should approximately half the contribution of the parent function to overhead.
2021-09-10 23:07:10 +10:00
Matt Joiner
016bf1b07c Optimize sortPeersForPiece in allocatePendingChunks 2021-09-10 23:07:10 +10:00
Matt Joiner
0d10a1b53a Optimize Torrent.worstBadConn 2021-09-10 23:07:10 +10:00