[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] maint: cleanup size determination in sort [was: overly aggressiv
From: |
Bernhard Voelker |
Subject: |
[PATCH] maint: cleanup size determination in sort [was: overly aggressive memory usage by sort.c] |
Date: |
Thu, 14 Jun 2012 08:01:54 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120421 Thunderbird/12.0 |
On 06/11/2012 07:24 PM, Paul Eggert wrote:
> On 06/11/2012 01:47 PM, Voelker, Bernhard wrote:
>> Am I wrong?
>
> I think so. The newly inserted code
> "if (total * 0.75 < size) size = total * 0.75;"
> is independent of the limits affected by
> the ulimit and plimit commands. In your example
> 'sort' will consume 4 * 15/16 GB if physmem_available
> reports 4 GB available.
Thanks for the clarification. I was confused.
Here's a patch to move the code regarding physical/available/total
memory down to where it's used (on top of your patch).
Have a nice day,
Berny
>From 1957c9a46e0427b2bbb346c2cb29710e7cbd6182 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <address@hidden>
Date: Thu, 14 Jun 2012 07:54:34 +0200
Subject: [PATCH] maint: cleanup size determination in sort
* src/sort.c (default_sort_size): Move physmem code "down" to first use.
---
src/sort.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/sort.c b/src/sort.c
index f21e092..c0d0c84 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -1405,11 +1405,6 @@ specify_nthreads (int oi, char c, char const *s)
static size_t
default_sort_size (void)
{
- /* Let MEM be available memory or 1/8 of total memory, whichever
- is greater. */
- double avail = physmem_available ();
- double total = physmem_total ();
- double mem = MAX (avail, total / 8);
struct rlimit rlimit;
/* Let SIZE be MEM, but no more than the maximum object size,
@@ -1435,6 +1430,12 @@ default_sort_size (void)
size = rlimit.rlim_cur / 16 * 15;
#endif
+ /* Let MEM be available memory or 1/8 of total memory, whichever
+ is greater. */
+ double avail = physmem_available ();
+ double total = physmem_total ();
+ double mem = MAX (avail, total / 8);
+
/* Similarly, leave a 1/4 margin for physical memory. */
if (total * 0.75 < size)
size = total * 0.75;
--
1.7.7
- overly aggressive memory usage by sort.c, Jeff Janes, 2012/06/07
- Re: overly aggressive memory usage by sort.c, Pádraig Brady, 2012/06/07
- Re: overly aggressive memory usage by sort.c, Jim Meyering, 2012/06/11
- Re: overly aggressive memory usage by sort.c, Paul Eggert, 2012/06/11
- Re: overly aggressive memory usage by sort.c, Paul Eggert, 2012/06/11
- RE: overly aggressive memory usage by sort.c, Voelker, Bernhard, 2012/06/11
- Re: overly aggressive memory usage by sort.c, Paul Eggert, 2012/06/11
- [PATCH] maint: cleanup size determination in sort [was: overly aggressive memory usage by sort.c],
Bernhard Voelker <=
- Re: [PATCH] maint: cleanup size determination in sort [was: overly aggressive memory usage by sort.c], Jim Meyering, 2012/06/20
- Re: [PATCH] maint: cleanup size determination in sort [was: overly aggressive memory usage by sort.c], Jeff Janes, 2012/06/20
- Re: [PATCH] maint: cleanup size determination in sort [was: overly aggressive memory usage by sort.c], Jim Meyering, 2012/06/20
- Re: [PATCH] maint: cleanup size determination in sort [was: overly aggressive memory usage by sort.c], Paul Eggert, 2012/06/20
- Re: overly aggressive memory usage by sort.c, Jeff Janes, 2012/06/12