Skip to content

Increase stdin chunksize from 16 to 1024 chars - #771

Merged
Tess Gauthier (tgauth) merged 1 commit into
PowerShell:latestw_allfrom
lhecker:stdin-chunk-size
Jan 13, 2025
Merged

Tess Gauthier (tgauth) merged 1 commit into
PowerShell:latestw_allfrom
lhecker:stdin-chunk-size

Conversation

@lhecker

@lhecker Leonard Hecker (lhecker) commented Dec 20, 2024 •

Copy link
Copy Markdown

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 actually
a lot "more true" for stdin than it would be for any file:
Since the stdin pipe is unbuffered and synchronous, the round-trip
overhead 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.

@tgauth

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@tgauth Tess Gauthier (tgauth) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tgauth
Tess Gauthier (tgauth) merged commit 8fe096c into PowerShell:latestw_all Jan 13, 2025
@DougSmythies

Copy link
Copy Markdown

I believe the issue addressed herein is the cause of my troubles when pasting from the clipboard into a file being edited with the nano editor on a linux computer, which uses "bracketed pastes". Sometimes the "end of pasted text" ESCAPE sequence is being broken up. PuTTY works fine, but the windows ssh client has issues. I started a discussion here a few days ago.

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.

4 participants