Increase stdin chunksize from 16 to 1024 chars #771
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
This bumps the chunk size for
stdin
from 16 to 1024 chars.PR Context
It would be very unusual to
read()
from a file with a 16-byte buffer.The same is true for
stdin
, but counter-intuitively it's actuallya lot "more true" for
stdin
than it would be for any file:Since the
stdin
pipe is unbuffered and synchronous, the round-tripoverhead for reading from it is exorbitantly high. To put it into
perspective, on Windows the call overhead alone is roughly the same
as subsequentially reading in the order of 100K characters.
The increased buffer size has an immediately noticeable effect on
the interactive shells I've tested. Pasting content into a prompt now
appears immediately and atomically, while previously it would only
progressively arrive and get syntax highlighted repeatedly (= flicker).
Another nice benefit is that some shells have trouble determining
whether an escape character is a sequence inducer or a lone escape
character. Increasing the buffer size reduces the chance for hitting
this edge case from 1/16th (6%) to 1/1024th (0.1%) and makes it
very unlikely to occur at all for inputs <1024 characters.
This issue is what prompted me to make this modification.