Re: [HACKERS] new heap manager mmalloc

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] new heap manager mmalloc
Date: 1999-01-28 18:57:32
Message-ID: 23673.917549852@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us> writes:
> Actually, our problem is not malloc itself. Most Unix OS's have pretty
> good malloc's, tuned to their OS. The problem is the number of times we
> call it.

Well, some malloc libs are noticeably better than others, but as long
as the operating assumption is that any allocated block can be freed
independently of any other one, it's hard to do a *lot* better than
a standard malloc library. You have to keep track of each allocated
chunk and each free area, individually, to meet malloc/free's API.

What we need to do is exploit the notion of pooled allocation
(contexts), wherein the memory management apparatus doesn't keep track
of each allocation individually, but just takes it from a pool of space
that will all be freed at the same time. End of statement, end of
transaction, etc, are good pool lifetimes for Postgres.

We currently have the worst of both worlds: we pay malloc's overhead,
and we have a *separate* bookkeeping layer on top of malloc that links
allocated blocks together to allow everything to be freed at end-of-
context. We should be able to do this more cheaply than malloc, not
more expensively.

BTW, I already did something similar in the frontend libpq, and it
was a considerable win for reading large SELECT results.

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-01-28 19:39:15 Re: [HACKERS] Postgres Speed or lack thereof
Previous Message Tom Lane 1999-01-28 18:43:05 Theory and practice of free software