freenet/fred — pull request #298 by bertm (2014-10-29 16:55:46+00:00)
Title: Packet format: simple efficiency improvements

This is pull request represents my first step in an attempt to make fred more resource-efficient on the network and packet level. Changes (apart from some minor readability improvements):

### PacketThrottle
* add method to report multiple lost packets, so we can call that instead of
iterating over `notifyOfPacketLost(…)`

### NewPacketFormatKeyContext
* reduce the operations inside a `synchronized(){}` block to a bare minimum
* only keep track of the sent times of *lost* packets: if a packet is not lost,
we still have a SentPacket that keeps track of its own sent time (this also
reduces the amount of work in ack() for the most common code path)
* reduce bounds on packets to track sent time of from 16384 to 128 (we don't
expect that many *lost* packets on short notice, and if we do, not having a
super-accurate RTT estimate is the least of our problems)
* improve `ack(…)` CPU efficiency by using `SentTimeCache` instead of `SentTimes`
(we're no longer concerned about memory given the above, so optimize for
speed)
* use `for(item : collection)` wherever applicable for readability

### SentTimeCache
* this class replaces `SentTimes`
* uses a `LinkedHashMap` with O(1) lookup instead of a linear search
* uses more memory than `SentTimes` did, but we shouldn't care anymore

### SentTimes
* removed since it's highly inefficient by design and is no longer used