Paul Eggert wrote: > On 06/11/2012 03:02 AM, Paul Eggert wrote: > > * src/sort.c (default_sort_size): Do not exceed 3/4 of total memory > > Come to think of it, that patch is too conservative, as it > limits things to at most 3/8 of total memory. The 3/4 limit > should be applied after 'size' is halved, not before. Here's > a better patch:
Then shouldn't the * 0.75 be _instead_ of the /2 then? > size_t size = SIZE_MAX; > if (getrlimit (RLIMIT_DATA, &rlimit) == 0 && rlimit.rlim_cur < size) > size = rlimit.rlim_cur; > @@ -1434,6 +1435,10 @@ default_sort_size (void) > size = rlimit.rlim_cur / 16 * 15; > #endif > > + /* Similarly, leave a 1/4 margin for physical memory. */ > + if (total * 0.75 < size) > + size = total * 0.75; > + and I'd put it before the rlimit calculation: e.g. a system has 8GB of RAM, but the admin want sort to only take 4GB. He'll use ulimit or plimit to 4GB. With this patch, sort will only take 3GB. Am I wrong? Have a nice day, Berny
