Repository navigation
sort: handle compression subprocess failures - #14945
mattsu2020 wants to merge 3 commits into
Conversation
|
GNU testsuite comparison: |
This comment was marked as resolved.
This comment was marked as resolved.
c9fe52e to
8d968cb
Compare
Merging this PR will degrade performance by 12.95%1 warning, 1 note
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
|
significant perf regressions here |
| /// Consumes a newly generated SIGPIPE on EPIPE, preserving any already pending | ||
| /// signal and restoring the original mask even if the operation panics. | ||
| #[cfg(all(unix, not(target_vendor = "apple")))] | ||
| pub fn with_sigpipe_blocked<T>(write: impl FnOnce() -> std::io::Result<T>) -> std::io::Result<T> { |
There was a problem hiding this comment.
that's 4+ syscalls per buffered write (mask swap, 2 sigpending, restore), could we block SIGPIPE once around the whole tmp file write instead?
There was a problem hiding this comment.
I'll simplify the implementation
f9bc89c to
8086e84
Compare
8086e84 to
afa5d26
Compare
| } | ||
|
|
||
| #[cfg(unix)] | ||
| fn run_with_compressor(script: &str, input: &str, buffer_size: &str, expected_error: &str) { |
There was a problem hiding this comment.
these #!/bin/sh scripts will break on android (no /bin/sh there), test_compress_fail is skipped on android for that, probably the Android CI failure, no?
There was a problem hiding this comment.
fixed it.
Changed /bin/sh handling for Android.
| fn test_compress_failures_ignored_sigchld() { | ||
| let ts = TestScenario::new("sort"); | ||
| ts.fixtures.write("input", &compressor_input(600, 4, "")); | ||
| for script in [ |
There was a problem hiding this comment.
same three scripts as test_compressor_failure_after_input / _terminated_by_signal / _failure_after_output, could be dedup, no?
There was a problem hiding this comment.
Consolidated similar logic.
| use std::os::unix::fs::PermissionsExt; | ||
|
|
||
| #[test] | ||
| fn compression_pipe_final_flush_error() { |
There was a problem hiding this comment.
re-exec of the test binary, unwraps, env var modes... quite complex for a unit test, could it be an integration test in test_sort.rs instead?
5937cc0 to
d2069ff
Compare
58ffb04 to
ec60f02
Compare
Keep pipe failures local to temporary file writes without changing stdout or child signal behavior. Cover pending signals, unwinding, and inherited SIGCHLD dispositions in unit tests.
Report temporary write and flush failures with status 2, reject abnormal child exits, and reap compression children on error paths. Add regression tests for early exits, signals, intermediate merges, and closed stdout.
ec60f02 to
5e1fe6e
Compare
Compression subprocesses that exit early can terminate sort with SIGPIPE, and intermediate merge write failures can return status 1 instead of 2. Handle broken pipes and buffered write errors, reject abnormal child exits, and wait for compression and decompression children on error paths. Restore child waiting when SIGCHLD is inherited as ignored, while preserving normal SIGPIPE behavior for stdout.
Adds regression tests for early exits, failures after consuming all input or producing output, signal termination, and intermediate merge failures. The sort regression tests pass on macOS and Linux. The GNU shell test itself has not been run.
The current CodSpeed comparison mixes Rust 1.98.1 and 1.99.0 between BASE and HEAD. Paired Linux/aarch64 runs using Rust 1.99.0 did not reproduce the reported large sort and split slowdowns; a matched-toolchain CodSpeed comparison is still needed.
Refs #14705 (sort/sort-compress-proc.sh).
Closes #14951