Write each rendered source line as one output operation - #3993
Open
Matei02355 wants to merge 2 commits into
Open
Write each rendered source line as one output operation#3993Matei02355 wants to merge 2 commits into
Matei02355 wants to merge 2 commits into
Conversation
Matei02355
marked this pull request as ready for review
September 7, 2026 17:36
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.
Colored Git logs produce many output writes for ANSI segments and sidebar cells, adding overhead when bat feeds a pager.
Render each source line into a reusable string and submit it as one output operation. Preserve byte-for-byte formatting, short-write handling, I/O errors and per-line streaming. Release buffers larger than 64 KiB after their line. Unbuffered mode still submits each available input fragment; it does not wait for the next source line.
Add regression coverage for write counts across character, word and unwrapped output, short writers and broken pipes. Include a standalone benchmark that compares identically built release binaries through a draining pager and verifies output hashes before alternating timed runs.
Validation: all 476 all-feature tests passed (7 ignored), including the three new regressions. Clippy with warnings denied, formatting, whitespace checks and the library-only build passed. Baseline and candidate both emitted a complete line and subsequent partial input before stdin EOF.
On this Linux host, eight alternating runs of an 80,000-line colored log through a cat pager improved from a 1.862 s median to 0.920 s (2.02x). One million numbered lines improved from 3.604 s to 2.503 s (1.44x). Rust highlighting was approximately unchanged (1.077 s versus 1.031 s). The unchanged plain-output path varied from 36.5 ms to 39.0 ms. All four output hashes matched. These measure formatting and pipe overhead, not terminal-emulator performance; no Windows speed claim is made.
Fixes #1147.