Repository navigation
fix(tsrs_execute): poll and retry stdout writes on EAGAIN - #1017
oxc-captain[bot] wants to merge 1 commit into
Conversation
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
Performance change vs mainWorkflow run · main Clef gate: Clef estimated 37.3% default and single-threaded wall time, 30.3% peak RSS, 36.4% single-threaded instruction count impact probability. Release builds in fast mode (TSRS_FAST=1) with Hyperfine 2 hardware counters. After warming each binary, alternating main/PR pairs measure wall time at both the fast preset's default checker count and with --singleThreaded, with ten pairs per configuration by default. Instructions come from the single-threaded runs; peak RSS comes from the default-count runs.
Negative means the PR used less; positive means it used more. Deltas are medians of paired PR/main ratios for wall time and instructions. Single-threaded runs reduce scheduling noise; shared CI machines can still add noise to wall time. Measured medians (main → PR)
tsrs-lintThe main and PR |
What and why
When
tsrsinherited a stdout pipe inO_NONBLOCKmode, writes that filled the pipe buffer returnedEAGAIN(std::io::ErrorKind::WouldBlock) and were silently discarded. This made--listFilesOnlystop at the pipe-buffer size and exit0, and large diagnostic listings stop partway through, while the pinned TypeScript Go compiler (tsc-go) printed everything.Go's
cmd/tsc/sys.gousesos.Stdoutdirectly; the Go runtime parks the goroutine and polls the descriptor onEAGAIN, so writes appear to block until the reader drains the pipe. tsrs now matches that behavior: aStdoutWriterwrapsstd::io::Stdout, polls forPOLLOUTonWouldBlock/Interrupted, and retries.The existing
broken_pipeintegration test still covers the case where the reader closes; this change only affects the live-but-full pipe case.Evidence
microsoft/TypeScript@v7.1-beta,3e9236361fa97a9e6c685f4833ac457ae2d8c50a):--listFilesOnlyand at a partial diagnostic count for error listings.tsc-go.crates/tsrs_cli/tests/integration/nonblocking_stdout.rswith two regression tests;list_files_only_is_complete_on_a_non_blocking_stdoutfails before the fix and passes after it.cargo test --profile dev --locked -p tsrs_cli --test integration -- broken_pipe nonblocking_stdout --test-threads=1:ok. 3 passed; 0 failed.tools/regressions.sh target/debug/tsrs: all 54 regression cases pass.cargo clippy --all-targets --locked --config 'build.warnings="deny"' -p tsrs_cli -p tsrs_execute: passes.node tools/lint/source.mjs: passes.Closes #1015.
Automated triagebot fix.