aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-08-05 15:19:02 +0100
committerRon Yorston <rmy@pobox.com>2021-08-05 15:19:02 +0100
commitc4cbc518d8bbc8ce051406c90f2ce12595925e83 (patch)
tree52366b15fe9db822101b6a5f394d82895bca6ec7
parentd3fbc42330d954378d2514436c7db6aff81d04db (diff)
downloadbusybox-w32-c4cbc518d8bbc8ce051406c90f2ce12595925e83.tar.gz
busybox-w32-c4cbc518d8bbc8ce051406c90f2ce12595925e83.tar.bz2
busybox-w32-c4cbc518d8bbc8ce051406c90f2ce12595925e83.zip
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.
-rw-r--r--coreutils/split.c8
1 files changed, 7 insertions, 1 deletions
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)
78 return old; 78 return old;
79} 79}
80 80
81#if !ENABLE_PLATFORM_MINGW32
81#define read_buffer bb_common_bufsiz1 82#define read_buffer bb_common_bufsiz1
82enum { READ_BUFFER_SIZE = COMMON_BUFSIZE - 1 }; 83enum { READ_BUFFER_SIZE = COMMON_BUFSIZE - 1 };
84#endif
83 85
84#define SPLIT_OPT_l (1<<0) 86#define SPLIT_OPT_l (1<<0)
85#define SPLIT_OPT_b (1<<1) 87#define SPLIT_OPT_b (1<<1)
@@ -97,8 +99,12 @@ int split_main(int argc UNUSED_PARAM, char **argv)
97 unsigned opt; 99 unsigned opt;
98 ssize_t bytes_read, to_write; 100 ssize_t bytes_read, to_write;
99 char *src; 101 char *src;
100 102#if ENABLE_PLATFORM_MINGW32
103 size_t READ_BUFFER_SIZE = 16*1024;
104 char *read_buffer = xmalloc(16*1024);
105#else
101 setup_common_bufsiz(); 106 setup_common_bufsiz();
107#endif
102 108
103 opt = getopt32(argv, "^" 109 opt = getopt32(argv, "^"
104 "l:b:a:+" /* -a N */ 110 "l:b:a:+" /* -a N */