Re: Bug in 9.6 tuplesort batch memory growth logic

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Geoghegan <pg(at)heroku(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bug in 9.6 tuplesort batch memory growth logic
Date: 2016-09-06 13:17:55
Message-ID: 17301.1473167875@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Geoghegan <pg(at)heroku(dot)com> writes:
> While working on my parallel CREATE INDEX patch, I came across a
> problem.

I took a quick look at this. I do not follow the logic in this new bit:

+ if (availMemLessRefund <=
+ (int64) state->activeTapes * ALLOCSET_DEFAULT_INITSIZE)
+ return;

It doesn't seem to me that this limit has anything to do with anything,
and the comment claiming only that it's "noncritical" isn't helping.
If the point is to prevent the later LACKMEM check from failing, then
certainly there is something critical somewhere. I'd rather see this
explained as "we need at least X, but we choose to require at least Y
to avoid repalloc thrashing". And maybe the code should use Max(X,Y)
rather than blindly assuming that ALLOCSET_DEFAULT_INITSIZE exceeds
whatever the true minimum is.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2016-09-06 13:38:43 Re: Proposal for changes to recovery.conf API
Previous Message Amit Kapila 2016-09-06 13:14:44 Re: condition variables