This adds a sync.Pool that stores bufio.Readers that can be re-used across messages. Previously, we were creating a new bufio.Reader for each new message. This allocates a buffer and results in a malloc call for each new message which can be very inefficient in high throughput environments. By introducing a sync.Pool we are able to re-use those allocations across multiple messages, dramatically reducing the cpu hit.
Solves #16
This adds a
sync.Pool
that storesbufio.Reader
s that can be re-used across messages. Previously, we were creating a new bufio.Reader for each new message. This allocates a buffer and results in amalloc
call for each new message which can be very inefficient in high throughput environments. By introducing a sync.Pool we are able to re-use those allocations across multiple messages, dramatically reducing the cpu hit.