Repository navigation
WIP: procsub drain faces — varredir_close completion close (#1646) + endpoint read tax (#1951) - #2017
Merged
Merged
Conversation
… not at application (rubash#1646) GNU redir.c do_redirection_internal (redir.c:976-985): with REDIR_VARASSIGN and the varredir_close shopt (builtins/shopt.def:269 varassign_redir_autoclose), the descriptor is only REGISTERED for closing at application time via add_undo_close_redirect -- the close itself happens when undo_redirections runs at the owning command's end. rubash closed inline inside execute_dynamic_fd_var_redirect, so the owning command's own >&$var write was rejected with EBADF: the data never reached the descriptor at all. For a >(consumer) stream the whole payload was silently lost; for a plain file the command failed with rc=1 and an empty target. Record the fd in Executor::deferred_varredir_closes at application time instead (redirection and heredoc forms alike), and drain the records a command added from execute_command -- the per-command bracket -- with watermark discipline so nested commands keep their own closes. A descriptor an external command's undo already closed during dispatch is skipped, so a recycled number is never closed by mistake; drain errors are swallowed like the shell-exit sweep's, since a procsub body's status never fails its owning command. Exit-path drain itself was verified complete before this change (the rubash#1336 sweep): -c, stdin, script-file, exit-builtin and EXIT-trap routes all deliver the accumulated stream byte-exact; the remaining delta this commit removes is the application-time close. Regression pins in tests/regression.rs (mod issue_1646): varredir_close procsub + plain-file survival, persistent drain-at-exit, default-mode accumulation.
…#1951) Re-measurement verdict for the #1951 constant tax (full data in the cluster report): the ~0.29ms/line endpoint-specific tax measured at the audit freeze tip is gone on current master -- the streamed endpoint landed by rubash#1952 plus the F5 work (PR #1914) replaced the materialized endpoint it lived on. Same-window decomposition (Linux, same machine) now shows the while-read face tracking the engine's general per-command floor: the endpoint drains at external cat speed, and the shell-side read premium is source-independent (regular file, pipe and procsub within noise of each other). GNU's own pipe reads are byte-wise by design (read.def:668 sets unbuffered_read for pipe input; zreadc buffering covers the file face, where rubash already buffers), so no endpoint mechanism fix remains that would not either duplicate the floor-tax work tracked by rubash#682 / rubash#2005 or diverge from GNU. These two pins guard the re-measured face in CI: exact line count at 20k lines and whole, ordered records off the streamed endpoint.
caomengxuan666
marked this pull request as ready for review
October 29, 2026 01:13
This was referenced Oct 29, 2026
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.
Two process-substitution drain faces, one commit per issue. Full evidence: cluster REPORT (fix-procsub-drain).
#1646 (commit f5a3d82) — FIXED. sharper than filed: the exit drain itself is complete on current master (finish_shell sweep delivers byte-exact output across -c/stdin/script/exit-builtin/EXIT-trap routes, md5-verified vs GNU 5.3.20). The live data-loss: with
shopt -s varredir_close, a{var}descriptor was closed at redirect-APPLICATION time instead of at the owning command's completion (GNU redir.c:976-985 only registers add_undo_close_redirect at application; the close runs with undo_redirections at command end). The command's own>&$varwrite was rejected EBADF — a>(...)consumer's stream lost wholesale; a plain-file target left the command at rc=1 with an empty file. Fix: record at application (Executor::deferred_varredir_closes), drain at the execute_command bracket with watermark discipline; skip numbers an external dispatch already closed/recycled. Pins: tests/regression.rs mod issue_1646 (4 tests, GNU 5.3.20 expectations).#1951 (commit 1ccdd9e, pins only) — re-measurement verdict: the endpoint-specific tax is GONE; no endpoint mechanism fix remains. Measured per the issue's own protocol (release, Linux, same machine, interleaved): procsub while-read now runs at 3.2x GNU — the BEST relative face among read shapes — tracking the engine's general per-command floor, not an endpoint tax (the audit-era 32x was the materialized endpoint replaced by #1952 streaming + F5 #1914; the issue itself prescribed re-measuring after streaming). Endpoint drains at external-cat speed (0.7us/line); the read premium is source-independent (file/pipe/procsub within noise). GNU reads pipes byte-wise BY DESIGN (read.def:668 unbuffered_read for pipe input; zreadc buffering is the file face, where rubash already buffers) — buffering pipes would diverge from GNU and break fd sharing. Residual homes: floor tax = #682, while-read shape = #2005. Two pins guard the re-measured face (exact 20k count; whole ordered records).
CI: all green except the niubash canary's ledger-cmp step (known transitional red — niu-side v4 sync rides niubash#668; this branch does not touch the ledger).
Fixes #1646