leodido / go-syslog

Blazing fast syslog parsers
MIT License
30 stars 3 forks source link

feat(octetcounting): re-use readers #18

Closed sinkingpoint closed 2 months ago

sinkingpoint commented 2 months ago

Solves #16

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.