Repository navigation
fix(seq,du,sed): buffered seq output, POSIX drive-form operands for du/sed, CHANGELOG #1167/#1169 - #1178
Merged
Conversation
…th (issue #1173) safePrint issues one WriteFile per call, so per-line emission paid a kernel transition two-three times per line (~30us/line piped; 100k lines ~332ms while GNU needs ~5ms). Lines now assemble into a 64 KiB buffer flushed in large chunks, integral first/increment sequences (default fixed format, precision 0, no --format/-w, |operands| <= 2^52) emit through std::to_chars like GNU seq.c's integer bypass, and the floating path drops the per-line size-query snprintf round trip. 100k lines, release build: seq 332ms -> ~45ms, seq | wc 903ms -> ~45ms (GNU/WSL oracle: 7-10ms; residual is the ~40ms Windows process spawn). Byte stream unchanged: new seq_large_range_buffered_output_matches_gnu_bytes pins 588895 bytes/100000 lines across several flush rounds.
…ndary (issue #1174) du rejected '/d/...' operands with ENOENT while accepting 'D:/...' and sed could not read them either — the L2 self-parse contract (tools resolve POSIX operands themselves) was unevenly applied. Both now route operands through native_path::make_api_path_operand_w/normalize_api_operand, the same boundary grep/wc/head/find already use: - du: traversal operands (and -X exclude files, --files0-from sources) fold '/d/src', '/cygdrive/d/src' and /dev pseudo-paths to their Win32 form; operand line and child entries agree on the resolved forward-slashed spelling (Savannah #13956) while the #1159 trailing-separator collapse and error messages keep the operand text as typed. - sed: input operands (glob patterns included) fold before expansion/open, and with -i the folded path is what gets replaced; -f script files and the r/w/W script-embedded paths resolve the same way. Diagnostics and the '='/F filename display keep the operand text as typed. GNU oracle (WSL coreutils): du -sh /usr -> '8.5G /usr' rc=0. New tests cover the dual forms: du -sh '/d/...' vs 'D:/...', sed -n 1p, sed -i and sed -f through '/d/...' paths.
…wn resolver in [Unreleased] (issue #1175) #1169 (GNU execvp-style child resolution: PATH-only bare-name search with no cwd/System32 shadowing, POSIX PATH spellings normalized) and #1167 (touch NTFS literal-glob platform deviation documented, test exemption registered) were merged without a CHANGELOG entry. PR #1171's own fixes (#1170/#1168/ #1166) were already recorded at merge time (d4210c7), so no duplicate entry is added for it.
caomengxuan666
added a commit
that referenced
this pull request
Oct 13, 2026
…on (#1180) - seq: 64 KiB chunked stdout + integral to_chars fast path, measured 332ms -> ~45ms on 100k lines, byte stream unchanged (#1173). - du, sed: POSIX drive-form operands resolve through the shared operand boundary like grep/wc/head/find (#1174). - Retitle [Unreleased] to [1.1.7] (date slot left for the release commit). The #1176/#1177 wpm supply-chain entries were already recorded by #1179 itself.
This was referenced Oct 18, 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.
Closes #1173, closes #1174, closes #1175.
Three independent tickets, one commit each.
#1173 — seq: batch stdout + integral to_chars fast path
Root cause.
safePrintissues oneWriteFileper call; seq emitted per line (separator + number), paying a kernel transition two-three times per line (~30us/line piped).Fix (src/commands/seq.cpp):
--format, no-w, and all operands within the exact-integer double range (<= 2^52, which also keeps the range test on the next item exact) emit throughstd::to_chars. The endpoint-rescue can never fire on an integral sequence (an integral NEXT equal to LAST satisfiesin_range), so the loop is a straight integer walk.snprintfper line into a stack buffer instead of a size-query + write pair; the default format string is built once (overlong outputs fall back to the old heap path).Benchmark (seq 1 100000, same box, warm runs):
Target met: 100k lines total <50ms in release. The residual vs GNU is the ~40ms Windows process-spawn floor (
seq 1 1costs ~40ms release), not per-line work (now ~0.05us/line).New tests:
seq_large_range_buffered_output_matches_gnu_bytes(588895 bytes / 100000 lines across several flush rounds, first/last bytes pinned) and a-s,,50k-line variant asserting flush boundaries keep the byte stream. Differential-tested byte-identical against WSL GNU seq on 12 integral/decimal sequences incl.10 -2 1,1 2 9.5,1 0.5 5.Out-of-scope observation (pre-existing on main, untouched here):
seq -w 1 2 10pads to the max emitted value width instead of GNU's width-of-LAST (01 03 05 07 09vs GNU01 03 05 07 09padded to 2 with last=10 wider than every emitted item).#1174 — du/sed: POSIX
/d/...operands resolve through the shared boundaryRoot cause. The L2 self-parse contract was uneven: grep/wc/head/find route path operands through
native_path, but du took operands straight into Win32 calls (ENOENT for/d/repo) and sed opened them verbatim.Fix — both now use the same boundary helpers as grep/wc/head:
make_api_path_operand_w(/d/src,/cygdrive/d/src, /dev pseudo-paths);-Xexclude files and--files0-fromsources normalize at open. Operand line and child entries agree on the resolved forward-slashed spelling (Savannah #13956); the [bug] du 对带尾斜杠参数输出双斜杠路径:du -h src/ 打印 src//bin(GNU 归一化) #1159 trailing-separator collapse is preserved against the raw operand and error messages keep the text as typed.-ithe folded path is what gets atomically replaced;-fscript files and the r/w/W script-embedded paths resolve the same way. Diagnostics and the=/F filename display keep the operand text as typed.Evidence. RED (main):
du -sh /c/...rc=1 ENOENT whiledu -sh C:/...rc=0;sed -n 1p /c/.../in.txtrc=2. GREEN: both forms rc=0 with identical sizes;sed -i/sed -fwork through POSIX paths. GNU oracle (WSL):du -sh /usr->8.5G /usrrc=0. New dual-form tests:du_accepts_posix_drive_form_operands(du -sh, sizes equal across forms),du_accepts_posix_drive_form_without_summarize,sed_accepts_posix_drive_form_operands(sed -n 1p),sed_in_place_accepts_posix_drive_form_operand,sed_script_file_accepts_posix_drive_form_operand.#1175 — CHANGELOG [Unreleased] completion
execvp-style resolver (PATH-only bare-name search, no cwd/System32 shadowing, POSIX PATH spellings normalized).Verification
-DFETCHCONTENT_SOURCE_DIR_WINUXCMD_PCRE2pointing at a local pcre2 10.47 checkout because the FetchContent download is blocked in my sandbox; CI downloads normally.