Skip to content

split: name the file and strip the errno in wasi open errors - #16272

Merged
sylvestre merged 1 commit into
uutils:mainfrom
eduardomourar:wasi-p1/split-wasi-open-error
Nov 14, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
eduardomourar:wasi-p1/split-wasi-open-error

Conversation

@eduardomourar

Copy link
Copy Markdown
Contributor

The bare io error from OpenOptions::open did not say which file failed. Wrap it with the filename, matching the message other platforms give.

Comment thread src/uu/split/src/platform/wasi.rs Resolved
Comment thread tests/by-util/test_split.rs Resolved
Comment thread tests/by-util/test_split.rs Resolved
@eduardomourar
eduardomourar force-pushed the wasi-p1/split-wasi-open-error branch from ba23d78 to 08fa13f Compare November 8, 2026 17:14
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 155.30 MB (+60 KB, +0.04%)

Significant per-binary changes:
  printenv     1.09 MB ->    1.15 MB  (+60 KB, +5.36%)

@eduardomourar
eduardomourar force-pushed the wasi-p1/split-wasi-open-error branch from 08fa13f to aa6deac Compare November 8, 2026 22:40
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/misc/usage_vs_getopt (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/pr/options is no longer failing!

@codspeed

codspeed Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 5 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 10 untouched benchmarks
⏩ 466 skipped benchmarks1


Comparing eduardomourar:wasi-p1/split-wasi-open-error (1b2ce97) with main (77b3b41)2

Open in CodSpeed

Footnotes

  1. 466 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (12e107f) during the generation of this report, so 77b3b41 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@eduardomourar
eduardomourar force-pushed the wasi-p1/split-wasi-open-error branch from aa6deac to 58692c5 Compare November 9, 2026 09:56
@sylvestre

Copy link
Copy Markdown
Contributor

@codspeedbot fix this regression

@codspeed

codspeed Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

@codspeedbot fix this regression

I pushed a fix in 1cef6f1. split_lines and split_numeric_suffix are now about 2x faster than on this branch before the fix.

What caused it

This PR's own changes (the wasi error wrapping and the round-robin index types) are not on the path these benchmarks run. The slowdown came from ba2cd75 "split: retry short writes in -b and -l modes", which is already on main. Since that commit, main's CodSpeed runs skipped the split benchmarks, so the PR's baseline still used an older split that didn't have it. This PR was the first run to measure that change.

That commit replaced write() with write_all() in LineChunkWriter, and that writer calls write once for every line (100,000 calls in split_lines). The number of system calls stayed the same, but the extra write_all loop and slice checks on each line added about 0.8 ms of instructions and about 3 ms of simulated cache cost.

The fix

LineChunkWriter::copy now writes all the lines in the read buffer that go to the same chunk with one write_all call, as GNU split does. It starts a new output file at the same points as before. The write_all short-write retry is kept.

Local CPU simulation results

Benchmark Before After
split_lines 7.12 ms 3.63 ms
split_numeric_suffix 7.23 ms 3.74 ms
split_bytes, split_number_chunks, split_number_chunks_round_robin unchanged unchanged

Time in system calls for split_lines dropped from about 135 ms to 13 ms.

Checks

  • All 155 test_split tests pass, and cargo fmt reports no issues.
  • Output matches GNU split for several -l values, inputs with and without a final newline, and stdin read in 3-byte pieces.

Not fixed

The split_bytes slowdown (-6.9%) is not addressed. Of its 54 µs, only about 8 µs are extra instructions (+4.5%); the rest is in the simulated cache cost. The CPU behind the PR run (Intel) also differs from the one behind the baseline run (AMD). The extra instructions come from the write_all retry that ba2cd75 added on purpose, so I left that path alone.

Comment @codspeedbot explain the split_bytes change if you'd like me to dig into it further.

Summary
  • Warming up the performance wizard...
  • Analyze the split regression — Regression comes from main commit ba2cd75 (custom_write -> write_all per line), not this PR's changes; split benches on main were skipped since then so the base still reflects the old code.
  • Batch line writes in LineChunkWriter — Each run of lines going to the same chunk is now written with one write_all call (as GNU does).
  • Run tests and simulation benchmarks — 155 split tests pass; output identical to GNU split; split_lines 7.12 ms -> 3.63 ms locally.
  • Commit and push — Pushed 1cef6f1.
  • Handling comment — Comment handling finished successfully

Was this response helpful? React with 👍 or 👎 to help us improve CodSpeedBot.

@sylvestre

Copy link
Copy Markdown
Contributor

thanks for picking this up!
Almost there: the round-robin fix still has no test on wasi (see inline), and the lines perf rewrite should be its own PR.

@eduardomourar
eduardomourar force-pushed the wasi-p1/split-wasi-open-error branch from 1cef6f1 to d181798 Compare November 11, 2026 22:42
@eduardomourar

Copy link
Copy Markdown
Contributor Author

@sylvestre, enabled test_number_kth_of_n_round_robin test and moved perf rewrite to #16357.

@eduardomourar
eduardomourar force-pushed the wasi-p1/split-wasi-open-error branch from d181798 to 9f77afc Compare November 12, 2026 12:28
@eduardomourar
eduardomourar force-pushed the wasi-p1/split-wasi-open-error branch from 9f77afc to 1b2ce97 Compare November 13, 2026 16:04
@sylvestre
sylvestre merged commit 425e8c2 into uutils:main Nov 14, 2026
143 of 144 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

@eduardomourar
eduardomourar deleted the wasi-p1/split-wasi-open-error branch November 15, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants