Re: tuplesort memory usage: grow_memtuples

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Peter Geoghegan <peter(at)2ndquadrant(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Greg S <stark(at)mit(dot)edu>
Subject: Re: tuplesort memory usage: grow_memtuples
Date: 2012-11-15 19:16:34
Message-ID: CA+Tgmob9t=Y=p7ikay3ugdr+qXJ_Y0FiE1reKpaZw2+zzF7AuA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 15, 2012 at 2:13 PM, Peter Geoghegan <peter(at)2ndquadrant(dot)com> wrote:
> On 15 November 2012 18:13, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> Ah, yeah. I wondered in passing about that but forgot to follow up on
>> it. The problem specifically is that the intermediate result
>> memtupsize * newmemtuples might overflow. I believe that the old
>> memtupsize can never be more than 2^26 bytes, because the allocation
>> limit is 1GB and each SortTuple is 16 bytes.
>
> Do you mean the intermediate result of memtupsize * allowedMem?

Yes.

> Oh,
> yeah, that could overflow rather easily on a platform where long is
> only 32-bit.

Or even 64-bit, with really large values of work_mem.

> We're multiplying the entire current allocation size of
> the array by the maximum length. I guess the fact that you didn't spot
> it made me overconfident. :-)

Ha!

So what's next here? Do you want to work on these issue some more?
Or does Jeff? I'd like to see this go in, but I'm not sure I have the
bandwidth to do the legwork myself.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-11-15 19:26:57 Re: pg_ctl reload -o "...."
Previous Message Peter Geoghegan 2012-11-15 19:13:58 Re: tuplesort memory usage: grow_memtuples