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 allocate pending frames #102

Open sergiu128 opened 1 year ago

sergiu128 commented 1 year ago

Sometimes, read and write operations will yield ping or pong frames that must be sent periodically or inline with client payloads. We put these control frames into a pending slice, which allocates a backing array every time. We must not do that.

Instead, all these control frames should be encoded directly into the destination buffer.

Depends on https://github.com/talostrading/sonic/issues/94