Repository navigation
Add an opt-in --stdout-buffering build option for line-heavy stdout - #2960
Merged
Merged
Conversation
A build that sets it keeps console and process.stdout bytes in the runtime's 64 KiB buffer when stdout is not a terminal. The buffer settles when it fills, before any stderr write, when the event loop sleeps, before a blocking stdin read, before process.kill, on process.exit and on an uncaught error, and at exit; a terminal keeps one write per call. Builds without the option are unchanged.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
--stdout-buffering settled buffered stdout only in the event loop's poll arm, so a loop waiting on a timer or on a child slept with lines still in the buffer. The settle now runs before whichever wait arm the loop takes. Buffered bytes also move from the C stream buffer to a runtime-owned buffer submitted through the loop that retries EINTR and continues short writes, because fflush(3) drops the stream's remaining bytes when a handled signal interrupts a write that transferred nothing. Every place the runtime flushed the C stream to publish stdout now settles that buffer first, so process.exit, an uncaught error, a warning, a child inheriting stdout and the exit hook all publish what the program wrote, and stdout keeps its order against stderr on a shared descriptor.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
scriptc build --stdout-bufferingkeeps console andprocess.stdoutbytes in the existing 64 KiB buffer when stdout is not a terminal; a terminal keeps one write per call, and builds without the option are unchanged.process.kill, onprocess.exitand on an uncaught error, so2>&1order and prompt-then-read match Node; a SIGKILL can lose up to 64 KiB.console.loglines to a pipe: 0.54 s with the option, 6.3 s without, 19.0 s in Node 24 (11.8x faster than the default build); fasta n=1M 11.2% faster (13.4% on the ABBA arm means), log-lines 3.35x faster.