Commit Graph

136 Commits

Author SHA1 Message Date
Matt Joiner f2e9eeba3b Check if torrent is closed before handling peer request data read failures
Should fix panics using storage after its been closed, like in https://github.com/anacrolix/torrent/runs/4017475163.
2021-10-27 15:14:11 +11:00
Matt Joiner 31985f1ea0 Add Peer.mustRequest 2021-10-26 15:03:04 +11:00
Matt Joiner 344ada8b7c Add disabled code for limiting wasted chunks 2021-10-25 21:37:25 +11:00
Matt Joiner e8067f741f Always count unhandled requests as pending
Fixes https://github.com/anacrolix/torrent/issues/679.
2021-10-25 16:36:58 +11:00
Matt Joiner 28726f737c Record webseed request result bytes against client stats
Should fix the issue where webseeds cause >100% useful data readings.
2021-10-25 16:17:55 +11:00
Matt Joiner e884b8079b Fix panic when sustaining unrejected requests after being choked
Fixes https://github.com/anacrolix/torrent/issues/680.
2021-10-25 13:00:56 +11:00
Matt Joiner ff3c186396 Add low requests check
This is an optimization for webseeds, which have 10 synchronous request routines, and if the request count dips below 10, some sit idle. There is probably something similar to be done with PeerConns, which won't update until there are zero requests, but there there is a timer to refresh updates, and the queues are very long (typically 512-2048).
2021-10-21 10:48:43 +11:00
Matt Joiner 8eec0b665e Update webseeds for peer requesting 2021-10-21 10:28:57 +11:00
Matt Joiner 92d3e1ed6d Remove unused peerImpl methods 2021-10-20 16:35:45 +11:00
Matt Joiner 9625553fd2 Demote some recent logs to debug 2021-10-20 11:22:35 +11:00
Matt Joiner e31e191c8d Improve protocol behaviour logging 2021-10-20 11:22:20 +11:00
Matt Joiner e51accb3e2 Don't error receiving unchoke while already unchoked 2021-10-19 14:08:56 +11:00
Matt Joiner 2f01dbab80 Include pending cancel count in peer status 2021-10-19 14:08:56 +11:00
Matt Joiner ccce2dba13 Improvements to request refreshing 2021-10-19 14:08:56 +11:00
Matt Joiner 1201ccc53b Refresh requests after a second of no updates 2021-10-19 14:08:56 +11:00
Matt Joiner a7d3296003 Use roaring.Bitmap.IsEmpty where appropriate 2021-10-19 14:08:56 +11:00
Matt Joiner 529aaa9b1f Use roaring bitmap for pending pieces
Also makes a significant optimization for peerHasWantedPieces possible.
2021-10-19 14:08:56 +11:00
Matt Joiner 23b4e2dc9c Wait for cancelled requests to be rejected per the spec 2021-10-19 14:08:56 +11:00
Matt Joiner 3f3bcab0d8 Track requests that are preserved across chokings 2021-10-19 14:08:56 +11:00
Matt Joiner 5f31bd83b3 Some fixes to pending request accounting 2021-10-19 14:08:56 +11:00
Matt Joiner b2cabe7dbf Handle allowed fast while choked when requests already exist in the same piece 2021-10-19 14:08:56 +11:00
Matt Joiner 4258ff7c60 Add missing request updates on cancels, rejects 2021-10-19 14:08:56 +11:00
Matt Joiner 7f236506cb Don't automatically delete requests if we're choked with fast extension 2021-10-19 14:08:56 +11:00
Matt Joiner 198a938700 Optimize Peer.peerHasWantedPieces 2021-10-19 14:08:56 +11:00
Matt Joiner 5e8f61abb5 Optimize request updates due to conn and reader state changes 2021-10-19 14:08:56 +11:00
Matt Joiner 4f87eed81a Extend nominal max requests upper bound to 2048 2021-10-19 14:08:56 +11:00
Matt Joiner 9aff9f3592 Extract pendingRequests 2021-10-19 14:08:56 +11:00
Matt Joiner 16c571b58b Add pprof labels for request updates and remove Client-wide requester 2021-10-19 14:08:13 +11:00
Matt Joiner 30b99e7102 Remove peer piece inclination and piece request order
These are vestigial data structures used with old request strategy implementations.
2021-10-19 14:08:13 +11:00
Matt Joiner 0f53cbf07e Change peer requesting to spread requests out evenly 2021-10-19 14:08:13 +11:00
Matt Joiner 1b78a9bcc6 Update requests on unchoke 2021-10-07 17:20:04 +11:00
Matt Joiner eab111dd84 Switch Peer.PieceAllowedFast and several request strategy inputs to raw roaring.Bitmaps
This is in preparation to support encoding request strategy run inputs for benchmarking.
2021-10-05 20:06:23 +11:00
Matt Joiner da1221dd50 Change Peer._peerPieces to use raw roaring Bitmap type
The wrapper type was from when roaring didn't support zero-alloc initialization.
2021-10-05 17:48:34 +11:00
Matt Joiner 719d5c6400 Wrap error with %w in mainReadLoop 2021-09-30 12:01:56 +10:00
Matt Joiner 63b3d2d211 Track dirty chunks in a single bitmap on Torrent 2021-09-20 18:52:54 +10:00
Matt Joiner 510877ea43 Reduce the diff to master and add peerRequesting feature const 2021-09-20 15:09:28 +10:00
Matt Joiner 1d2d1a9cde Store peer requests in a bitmap 2021-09-19 15:16:37 +10:00
Matt Joiner cd49f75cb9 When updating requests, only tickle writer if there are no requests pending
Just a quick attempt to reduce load for now. There'll be a much better way to do this.
2021-09-18 21:01:06 +10:00
Matt Joiner 21358ba458 Do peer requests separately for each peer 2021-09-18 20:34:14 +10:00
Matt Joiner d90c41c534 Add choking/allowed fast checks to Peer.shouldRequest 2021-09-18 19:00:21 +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 62c6fbc8f8
Clarify ownership of (*Torrent).chunkPool (#583)
Basically bind the lifetime of chunkPool to the torrent by using `sync.Pool` in lieu of `*sync.Pool`. Gives the GC ever so slightly less work to do.
2021-09-09 22:27:16 +10:00
Matt Joiner 72c74f7800 Remove unused code 2021-08-19 16:06:46 +10:00
Matt Joiner 22c5a94a6a Use roaring.Bitmap directly for completed pieces
Looking at improving the performance around this per https://github.com/anacrolix/torrent/discussions/547#discussion-3522317.
2021-08-16 11:07:10 +10:00
Matt Joiner d42f2516a4 Increase request update interval if there's no signalling 2021-08-01 22:52:51 +10:00
Matt Joiner 15f8e77519 Add explicit metadata extension types 2021-06-21 12:14:06 +10:00
Matt Joiner 7d9e2b18d6 Extract chansync to github.com/anacrolix/chansync 2021-06-07 13:01:40 +10:00
Matt Joiner c895a21a16 Track chunks read for webseed peers too 2021-06-07 13:01:40 +10:00
Matt Joiner 36f52d7a14 Apply next request state asynchronously 2021-06-07 13:01:40 +10:00
Matt Joiner d37dea1f61 Move peerConnMsgWriter into its own file 2021-06-07 13:01:40 +10:00