Re: Performance problem in aset.c - Mailing list pgsql-hackers

From Philip Warner
Subject Re: Performance problem in aset.c
Date
Msg-id 3.0.5.32.20000712142008.01e0fc20@mail.rhyme.com.au
Whole thread Raw
In response to Performance problem in aset.c  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Performance problem in aset.c  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Performance problem in aset.c  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
At 23:48 11/07/00 -0400, Tom Lane wrote:
>Another idea is to split the returned chunk and put the wasted part back
>as a smaller free chunk, but I don't think this solves the problem; it
>just means that the wasted space ends up on a small-chunk freelist, not
>that you can actually do anything with it.  But maybe someone can figure
>out a variant that works better.

Can you maintain one free list for each power of 2 (which it might already
be doing by the look of it), and always allocate the max size for the list.
Then when you want a 10k chunk, you get a 16k chunk, but you know from the
request size which list to go to, and anything on the list will satisfy the
requirement.

In the absolute worst case this will double your memory consumption, and on
average should only use 50% more memory. If this worries you, then maintain
twice as many lists and halve the wastage. 

The process of finding the right list is just a matter of examining the MSB
of the chunk size. If you want twice the number of lists, then look at the
top two bits etc.




----------------------------------------------------------------
Philip Warner                    |     __---_____
Albatross Consulting Pty. Ltd.   |----/       -  \
(A.C.N. 008 659 498)             |          /(@)   ______---_
Tel: (+61) 0500 83 82 81         |                 _________  \
Fax: (+61) 0500 83 82 82         |                 ___________ |
Http://www.rhyme.com.au          |                /           \|                                |    --________--
PGP key available upon request,  |  /
and from pgp5.ai.mit.edu:11371   |/


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Connection pooling.
Next
From: M.Feldtmann@t-online.de (Marten Feldtmann)
Date:
Subject: Re: Alternative new libpq interface.