Skip to content

Reduce allocation in `QueuePacketConn.QueueIncoming`.

QueueIncoming makes a copy of the passed in slice before queuing it. The idea behind this design is to make the function harder to misuse: the caller cannot modify the queued packet after calling QueueIncoming. But it means an extra malloc and memmove per queued packet. As long as the caller does not reuse the slice, it is okay not to make a copy and it's more efficient.

These allocations are suspected to be a cause of frequent garbage collections in #40086 (comment 2838372).