Skip to content

Comments

feat: size bufReader based on user's first Read() buffer#162

Closed
clementnuss wants to merge 1 commit intopires:mainfrom
clementnuss:dynamic-buffer-size
Closed

feat: size bufReader based on user's first Read() buffer#162
clementnuss wants to merge 1 commit intopires:mainfrom
clementnuss:dynamic-buffer-size

Conversation

@clementnuss
Copy link
Contributor

Defer bufReader creation until first use and size it to max(256, len(b)) where b is the user's Read() buffer.

This allows more data to be buffered from the OS initially, so users with large buffers receive more payload in a single Read() call after header parsing.

ℹ️ to spare memory, we might want to nil out bufReader when there is a proxy parsing error, but that should be a different commit/PR

Defer bufReader creation until first use and size it to
max(256, len(b)) where b is the user's Read() buffer.

This allows more data to be buffered from the OS initially,
so users with large buffers receive more payload in a single
Read() call after header parsing.
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.

1 participant