From: Paul Eggert Date: Sat, 25 Feb 2012 18:32:52 +0000 (-0800) Subject: sort: default to physmem/8, not physmem/16 X-Git-Tag: v8.16~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a507ed6ede5064b8f15c979e54e6de3bb478d73e;p=thirdparty%2Fcoreutils.git sort: default to physmem/8, not physmem/16 * src/sort.c (default_sort_size): Don't divide advice by 2. Just divide the hard limits by 2. This matches the comments. Reported by Rogier Wolff in http://bugs.gnu.org/10877 --- diff --git a/src/sort.c b/src/sort.c index 6875a6a93d..60ff415cfd 100644 --- a/src/sort.c +++ b/src/sort.c @@ -1414,13 +1414,9 @@ default_sort_size (void) struct rlimit rlimit; /* Let SIZE be MEM, but no more than the maximum object size or - system resource limits. Avoid the MIN macro here, as it is not - quite right when only one argument is floating point. Don't - bother to check for values like RLIM_INFINITY since in practice - they are not much less than SIZE_MAX. */ + system resource limits. Don't bother to check for values like + RLIM_INFINITY since in practice they are not much less than SIZE_MAX. */ size_t size = SIZE_MAX; - if (mem < size) - size = mem; if (getrlimit (RLIMIT_DATA, &rlimit) == 0 && rlimit.rlim_cur < size) size = rlimit.rlim_cur; #ifdef RLIMIT_AS @@ -1439,7 +1435,11 @@ default_sort_size (void) size = rlimit.rlim_cur / 16 * 15; #endif - /* Use no less than the minimum. */ + /* Return the minimum of MEM and SIZE, but no less than + MIN_SORT_SIZE. Avoid the MIN macro here, as it is not quite + right when only one argument is floating point. */ + if (mem < size) + size = mem; return MAX (size, MIN_SORT_SIZE); }