Merlin Moncure <mmoncure@gmail.com> writes:
> On Mon, May 2, 2011 at 11:09 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I did a bit of testing of this and committed it with minor adjustments.
> Thanks for the attribution -- I hardly deserved it. One question
> though: ALLOC_CHUNK_FRACTION was put to four with the language 'We
> allow chunks to be at most 1/4 of maxBlockSize'.
> further down we have:
> "+ * too. For the typical case of maxBlockSize a power of 2, the chunk size
> + * limit will be at most 1/8th maxBlockSize, so that given a stream of
> + * requests that are all the maximum chunk size we will waste at most
> + * 1/8th of the allocated space."
> Is this because the divide by 2 right shift halves the amount of
> wasted space, so that the maximum waste is in fact half again the
> fraction?
No, it's the overhead. The patch as you submitted it was forcing
allocChunkSize down to 512, because after subtracting off the
per-malloc-block overhead and the per-palloc-chunk overhead, it came to
the (correct) conclusion that 1024 didn't quite fit 8 times into 8192.
I thought that was probably excessive, so I backed off the fraction.
regards, tom lane