summaryrefslogtreecommitdiff
path: root/src/sort.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-03-16 16:09:31 +0100
committerJim Meyering <meyering@redhat.com>2011-03-16 16:30:02 +0100
commit4f591fdd0bb78f621d2b72021de883fc4df1e179 (patch)
tree10faa8cd67855bc3a16cf439c3cb57df689fbc44 /src/sort.c
parent8e4e1d484f88502dbe9336050232a5f90e0b68d4 (diff)
downloadcoreutils-4f591fdd0bb78f621d2b72021de883fc4df1e179.tar.xz
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
Diffstat (limited to 'src/sort.c')
-rw-r--r--src/sort.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/sort.c b/src/sort.c
index 9b8666afb..07d6765ac 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;