Repository navigation
split: create empty chunks deferred by the open files limit - #16738
Conversation
| break; | ||
| } | ||
| } | ||
| if !settings.elide_empty_files { |
There was a problem hiding this comment.
same guard twice, could the elide_empty_files check move into create_unopened? (byte mode never has unopened chunks with -e anyway)
There was a problem hiding this comment.
Done in 030037f. The check now lives only inside create_unopened, and the three call sites just call it.
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
This comment was marked as outdated.
This comment was marked as outdated.
e45ebc3 to
17b8a58
Compare
With -n N, -n l/N and -n r/N, output files that could not be opened upfront because of the open files limit were only opened once they received data. Chunks that stayed empty were then never created, or kept stale contents when a prefix was reused. Once input ends, open and close every chunk that was never opened, one at a time, so all chunks exist and are truncated like in GNU split. Fixes uutils#16737
17b8a58 to
258f4e7
Compare
|
Thanks for your PR |
Fixes #16737
With
-n N,-n l/Nand-n r/N,OutFiles::initdefers any output file it can't open because of the open files limit, and a deferred file is only opened once it receives data. When input ran out first, those chunks were never created, or kept their old contents when a prefix was reused, so reassembling the chunks returned bytes from the previous run.Once input ends,
create_unopenednow opens and closes every chunk that was never opened, one at a time, through the existinginstantiate_writer(so it still closes another writer if the limit is hit). All three-nmodes go through the sharedOutFilescode. With-e, the line and round robin modes skip this step, so elided chunks are still not created.The issue's repro under
ulimit -n 12now prints!and leaves 20 files. Before, byte mode printed!JKLMNOPQRST, and the line modes left only 9 of the 20 files.Tests:
test_limited_file_descriptors_truncates_unwritten_chunkscovers20,l/20andr/20under the sameNOFILElimit astest_round_robin_limited_file_descriptors. It checks that a fresh directory gets all 20 empty chunks, and that reusing a prefix with a shorter input reassembles to exactly the new input. It fails on main (missing chunk files) and passes with this change.cargo test --features split test_split, clippy,cargo fmt --checkandcargo docwith-Dwarningspass locally.One related thing I left alone:
instantiate_writertreats any open error as hitting the descriptor limit, so a chunk that can't be created for another reason (for example a directory namedxab) prints the "at file descriptor limit" message before the real error. That already happens on main in the round robin data path, and the reopen path inopen_output_filedrops the OS error, so telling the two apart needs its own change. Happy to send that as a follow-up.