File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -481,8 +481,17 @@ fn write_fast<R: FdReadable>(handle: &mut InputHandle<R>) -> CatResult<()> {
481481 let mut stdout_lock = stdout. lock ( ) ;
482482 #[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
483483 {
484- // If we're on Linux or Android, try to use the splice() system call
485- // for faster writing. If it works, we're done.
484+ // splice is slow for small files (https://github.com/uutils/coreutils/issues/10832)
485+ const SPLICE_THRESHOLD : u64 = 16 * 1024 ;
486+ let copied = io:: copy (
487+ & mut handle. reader . by_ref ( ) . take ( SPLICE_THRESHOLD ) ,
488+ & mut stdout_lock,
489+ ) ?;
490+ if copied < SPLICE_THRESHOLD {
491+ stdout_lock. flush ( ) ?;
492+ return Ok ( ( ) ) ;
493+ }
494+ // splice syscall is faster for large file
486495 if !splice:: write_fast_using_splice ( handle, & stdout_lock) ? {
487496 return Ok ( ( ) ) ;
488497 }
You can’t perform that action at this time.
0 commit comments