diff --git a/src/uucore/src/lib/features/pipes.rs b/src/uucore/src/lib/features/pipes.rs
index 3b7c4654b0..5483a38a9b 100644
--- a/src/uucore/src/lib/features/pipes.rs
+++ b/src/uucore/src/lib/features/pipes.rs
@@ -8,13 +8,18 @@
use crate::io::{RawReader, RawWriter};
use rustix::pipe::{SpliceFlags, fcntl_setpipe_size};
use std::{
+ cell::Cell,
io::{PipeReader, PipeWriter, Read, Write},
os::fd::AsFd,
- sync::OnceLock,
};
pub const MAX_ROOTLESS_PIPE_SIZE: usize = 1024 * 1024;
const KERNEL_DEFAULT_PIPE_SIZE: usize = 64 * 1024;
+thread_local! {
+ /// Cache empty pipe pair to avoid calling `pipe2` at each copy.
+ static PIPE_CACHE: Cell