mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
ackhandler: use a slice to keep track of sent packets (#3841)
* ackhandler: simplify deletion of old packets in packet history * ackhandler: use a slice to keep track of sent packets This is a vastly simpler data structure than the combination of map and linked list used before. It avoids using a linked list (bad cache locality) and a sync.Pool (for list elements), as well as having to do hash table lookups. In the future, this can be easily replaces with a ring buffer, avoiding all allocations. * ackhandler: don't store packets that were declared lost
This commit is contained in:
parent
6f07050269
commit
8f3a68b4eb
4 changed files with 244 additions and 205 deletions
|
@ -37,8 +37,10 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
})
|
||||
|
||||
getPacket := func(pn protocol.PacketNumber, encLevel protocol.EncryptionLevel) *Packet {
|
||||
if el, ok := handler.getPacketNumberSpace(encLevel).history.packetMap[pn]; ok {
|
||||
return el.Value
|
||||
for _, p := range handler.getPacketNumberSpace(encLevel).history.packets {
|
||||
if p != nil && p.PacketNumber == pn {
|
||||
return p
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -97,7 +99,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
})
|
||||
ExpectWithOffset(1, length).To(Equal(len(expected)))
|
||||
for _, p := range expected {
|
||||
ExpectWithOffset(2, pnSpace.history.packetMap).To(HaveKey(p))
|
||||
ExpectWithOffset(2, getPacket(p, encLevel)).ToNot(BeNil())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,7 +244,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
ExpectWithOffset(1, length+len(lostPackets)).To(Equal(len(expected)))
|
||||
expectedLoop:
|
||||
for _, p := range expected {
|
||||
if _, ok := pnSpace.history.packetMap[p]; ok {
|
||||
if getPacket(p, encLevel) != nil {
|
||||
continue
|
||||
}
|
||||
for _, lostP := range lostPackets {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue