Skip to content

Conversation

@gbegen
Copy link

@gbegen gbegen commented Feb 16, 2022

The default bufio.Reader buffer size of 4K is too small in some contexts. Use a buffer size of 64K instead.

@gbegen
Copy link
Author

gbegen commented Feb 16, 2022

As additional context, we have an app that outputs logs to stdout as JSON lines. When run under modd, the occasional long line gets broken into multiple lines with separating "\n" between them. This breaks the ability for our log readers to see the full JSON structure. Upping to 64K solves this at the modest expense of 60K per running process.

The default bufio.Reader buffer size of 4K is too small in some contexts. Use a buffer size of 64K instead.
@phillipgziprecruiter
Copy link

We are hitting this problem as well. 64k would be good, but making it configurable would be better. We have use cases where we may need a 1M size.

@phillipgziprecruiter
Copy link

I looked at the code closer, i think the problem is less about the buffer size but the code assumes that a complete line will fit within the buffer. The out function should only add a new line if isPrefix is false (https://pkg.go.dev/bufio#Reader.ReadLine).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants