Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/uucore/src/lib/features/pipes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,20 @@ pub fn splice_unbounded_auto(source: &impl AsFd, dest: &mut impl AsFd) -> Splice
#[inline]
pub fn send_n_bytes(input: impl AsFd, target: impl AsFd, n: u64) -> std::io::Result<u64> {
let pipe_size = n.min(MAX_ROOTLESS_PIPE_SIZE as u64) as usize;
let resize = pipe_size > KERNEL_DEFAULT_PIPE_SIZE;
Comment thread
abendrothj marked this conversation as resolved.
// improve throughput if output is pipe
// expected that input is already extended if it is coming from splice
if pipe_size > KERNEL_DEFAULT_PIPE_SIZE {
if resize {
let _ = fcntl_setpipe_size(&target, pipe_size);
}
let Ok((broker_r, broker_w)) = PIPE_CACHE.take().map_or_else(pipe::<false>, Ok) else {
let Some((broker_r, broker_w)) = PIPE_CACHE.take().or_else(|| {
// use std::io::pipe to avoid fcntl when it is not useful
let pair = std::io::pipe().ok()?;
if resize {
let _ = fcntl_setpipe_size(&pair.0, pipe_size);
}
Some(pair)
}) else {
return std::io::copy(&mut RawReader(input).take(n), &mut RawWriter(target));
};
let mut n = n;
Expand Down
Loading