talostrading / sonic

Sonic is a Go library for network and I/O programming that provides developers with a consistent asynchronous model, with a focus on achieving the lowest possible latency and jitter in Go.
MIT License
676 stars 16 forks source link

Do not heap allocate read/write handlers #103

Open sergiu128 opened 1 year ago

sergiu128 commented 1 year ago

In conn.go and packet.go we allocate on each read/write operation through getReadHandler or getWriteHandler. That is unnecessary. We have a solution in multicast.UDPPeer where instead of allocating a handler each time, we keep a reference to it and change its state on-demand on an async read/write.