From c4cbc518d8bbc8ce051406c90f2ce12595925e83 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 5 Aug 2021 15:19:02 +0100 Subject: split: improve performance The default buffer size doesn't seem to work very well on Windows. Increasing the buffer to 16K speeds up the splitting of a 1GB file into 100MB chunks by a factor of two. GitHub issue #224. --- coreutils/split.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/coreutils/split.c b/coreutils/split.c index 3fcfd95f2..9393423a1 100644 --- a/coreutils/split.c +++ b/coreutils/split.c @@ -78,8 +78,10 @@ static char *next_file(char *old, unsigned suffix_len) return old; } +#if !ENABLE_PLATFORM_MINGW32 #define read_buffer bb_common_bufsiz1 enum { READ_BUFFER_SIZE = COMMON_BUFSIZE - 1 }; +#endif #define SPLIT_OPT_l (1<<0) #define SPLIT_OPT_b (1<<1) @@ -97,8 +99,12 @@ int split_main(int argc UNUSED_PARAM, char **argv) unsigned opt; ssize_t bytes_read, to_write; char *src; - +#if ENABLE_PLATFORM_MINGW32 + size_t READ_BUFFER_SIZE = 16*1024; + char *read_buffer = xmalloc(16*1024); +#else setup_common_bufsiz(); +#endif opt = getopt32(argv, "^" "l:b:a:+" /* -a N */ -- cgit v1.2.3-55-g6feb