quinn
quinn copied to clipboard
Optimize PacketSpace::sent_packets
@Matthias247 reports that this is a performance bottleneck. It's currently a BTreeMap of packet numbers to frame metadata, and the required operations are append and random erase. The maximum size is roughly bounded by the round-trip time of the connection, since we declare packets lost and remove them from the list after an ACK is received for a packet number greater than that of the packet in question by more than the reordering threshold. Most removals are from the front, rather than the middle.
A good replacement would be a VecDeque<Vec<(u64, SentPacket)>>, where each inner Vec is at most a fixed size, and both levels are sorted by packet number.
Just to ack (ha!) that I just did some profiling and this definitely shows up in profiles.