mucaho/jnetrobust

Improve performance

mucaho opened this issue · 0 comments

As this library is also intended to work on Android, performance should be optimized where applicable

  • send only 1 packet (no duplicate ack/last ack fields) for multiple for retransmits
    -> add Controller.send(Collection<MultiKeyValue>): Packet
    -> add Controller.receive(Packet with Collection<MultiKeyValue>): Object
  • make sure that there is minimal object allocation inside scopes -> extract such local variables as fields
  • add object pools for Packet, MultiKeyValue, Iterator and co instead of instantiating new objects
    -> update serializer object creation strategy to use object pools
  • use practical initialCapacity parameters during collection initialization
  • use a rolling fixed size queue for pending acks, eg. a 256 size queue indexed by sequence number mod 256. changing to plain array much of the NavigableMap functionality is lost -> rather investigate alternative collection libraries with near zero garbage