Skip to content

split: add -u/--unbuffered - #16375

Merged
sylvestre merged 2 commits into
uutils:mainfrom
binhvq:split-unbuffered
Nov 27, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
binhvq:split-unbuffered

Conversation

@binhvq

@binhvq binhvq commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

GNU split has -u/--unbuffered ("immediately copy input to output with '-n r/...'"). We rejected it as an unknown argument.

Output files and filters are already written without buffering, so the only modes it changes are -n r/...:

  • the input is passed on as soon as it is read instead of one whole record at a time, so with (printf ab; sleep 2; printf 'c\n') | split -u -n r/1/1 the ab shows up right away, as with GNU;
  • with r/K/N, stdout is flushed after each write (it is line buffered, which does nothing with -t).

In the other modes it is accepted and does nothing, like GNU.

@codspeed

codspeed Bot commented Nov 12, 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
⏩ 476 skipped benchmarks1


Comparing binhvq:split-unbuffered (4187d46) with main (0714639)2

Open in CodSpeed

Footnotes

  1. 476 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 (932efe9) during the generation of this report, so 0714639 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

@sylvestre

Copy link
Copy Markdown
Contributor

thanks for looking into this!
The test doesn't cover the partial-record path yet, see the inline comment.
CI is red and CodSpeed reports a regression of 1 benchmark, please have a look. Please also squash the second commit into the first.

@@ -2566,6 +2566,32 @@ fn test_number_with_plus_prefix(
assert_eq!(files, expected_files, "-n {number}");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this gives the same output with or without -u. Could you please add a case with records longer than the buffer (---io-blksize=2)? That is where record_complete matters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test_unbuffered_record_longer_than_buffer with ---io-blksize=2, to files and with r/K/N. It fails if the chunk number moves on after a partial record.

@binhvq

binhvq commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

The CodSpeed one is split_number_chunks (-n 10), which this PR does not touch. Under callgrind every mode costs about 8k more instructions at startup, also with a one-line input, so it comes from the extra option. The red Tests job is the OpenBSD uucore doctest (E0463), and GNU printf fails on main too.

About squashing: would a squash merge work for you? Otherwise I can squash before it goes in.

@binhvq

binhvq commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Squashed into one commit; the only change is a reworded test comment.

@sylvestre
sylvestre force-pushed the split-unbuffered branch 2 times, most recently from b6ed3c1 to 66eba4d Compare November 21, 2026 23:23
With -n r/..., pass the input on as soon as it is read instead of one whole record at a time, and flush stdout after each write for r/K/N. In the other modes the option is accepted and changes nothing.
@sylvestre
sylvestre merged commit 9501946 into uutils:main Nov 27, 2026
107 of 108 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

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