Files
i2p.i2p/apps/i2psnark/java
zzz 697bb94f8f i2psnark: Smooth out request throttling
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
2026-08-22 10:22:50 -04:00
..
2026-06-11 18:17:36 -04:00