From 4f591fdd0bb78f621d2b72021de883fc4df1e179 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 16 Mar 2011 16:09:31 +0100 Subject: [PATCH] sort: avoid memory pressure of 130MB/thread when reading from pipe * src/sort.c (INPUT_FILE_SIZE_GUESS): Decrease initial allocation factor used to size buffer used when reading a non-regular file. For motivation, see discussion here: http://thread.gmane.org/gmane.comp.gnu.coreutils.general/878/focus=887 --- src/sort.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sort.c b/src/sort.c index 9b8666afb7..07d6765ace 100644 --- a/src/sort.c +++ b/src/sort.c @@ -319,8 +319,12 @@ static size_t merge_buffer_size = MAX (MIN_MERGE_BUFFER_SIZE, 256 * 1024); specified by the user. Zero if the user has not specified a size. */ static size_t sort_size; -/* The guessed size for non-regular files. */ -#define INPUT_FILE_SIZE_GUESS (1024 * 1024) +/* The initial allocation factor for non-regular files. + This is used, e.g., when reading from a pipe. + Don't make it too big, since it is multiplied by ~130 to + obtain the size of the actual buffer sort will allocate. + Also, there may be 8 threads all doing this at the same time. */ +#define INPUT_FILE_SIZE_GUESS (128 * 1024) /* Array of directory names in which any temporary files are to be created. */ static char const **temp_dirs; -- 2.47.2