- consolidate length rectification code
- fix rectification for file length > 2 GB
- make InputStream method public again, with the requirement
to call rectify() first for files
- clarify plen param requirement for files vs. pieces
- add plen param for byte[] method
- add debug output for empty hashes
The request throttler had several problems:
- Throttling was very laggy, but when it reacted it throttled too quickly.
- PartialPieces got returned back to PeerCoordinator,
and then back to PeerState, every few seconds, rather
than continuing steady-state in PeerState
- Holding the PartialPiece in the PeerCoordinator for
several seconds while staying interested is poor and risks snubbing
- Max request queue size was reduced far too quickly,
doing so exponentially when the reduction occurred linearly
- shouldRequest() called the request limiter second in the conditional,
so the estimator was not decayed properly when over down bw limit
- shouldRequest() used overDownBandwidthLimit() rather than _down.offer(),
ensuring a very slow and laggy feedback loop.
- Requests were added too quickly on unthrottle
Fix these by:
- Fixing and slowing max request queue size reduction to simulate
an exponential reduction over time when throttled
- Fixing shouldRequest() to always call offer() for both limiters
- Slow addition of requests after unthrottle to simulate
a linear increase over time
Log tweaks also
The request queue now mostly maintains a steady size,
and properly meters the requests.
The PartialPiece returns to the PeerCoordinator much less often,
and comes back to PeerState much quicker if it does.
Further tuning TODO
- For fast peers:
Do not rerequest, peer is expected to meet its BEP 6 obligation,
and rerequesting needlessly inflates the request bandwidth estimate
- Drop dup requests for pieces peers already have
- Remove old comment about future enhancements we already did
- Fix repeated PartialPiece log about hole filled in
- Log tweaks
Should improve d/l from qbittorrent that aggressively reorders
for large piece sizes, use a buffer instead,
in two spots: creating and rechecking.
Pass the hash instead of the piece to MetaInfo.checkPiece()
Remove now-unused methods.
- Refactor padding file addition, inspired by similar code in I2P+
Now will be called from Storage, not done on-the-fly during
MetaInfo creation, which was the wrong place.
- Skip padding files in PieceLayers constructor based on attributes
- toString() tweaks for logging
- Add method to generate piece hashes from a File
- Make InputStream methods private
- Fix subclass name
- Add alternate construtor for PieceLayers
- Change PieceLayers constructor exception class
For now, disable it, since we now have good bandwidth limiting
in snark, we don't need the additional throttling/drops in I2CP
causing more streaming issues and making snark/streaming analysis/optimization harder.
The I2CP limiter is also bad and old and needs to be completely rewritten or tossed out.