memory allocation and powers of two

From: David Schultz <dschultz(at)uclink(dot)Berkeley(dot)EDU>
To: pgsql-hackers(at)postgresql(dot)org
Subject: memory allocation and powers of two
Date: 2003-08-28 09:14:05
Message-ID: 20030828091405.GA39540@HAL9000.homeunix.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

While looking into a block size mismatch problem between
Postgresql and FreeBSD's FFS, I noticed that postgresql is making
some rather odd-sized requests to malloc(3): 0x2034, 0x2020,
0x4018, 0x8018, etc. Most malloc(3) implementations round large
allocations up to a multiple of a large power of 2---often the
hardware page size, so this is a pathological case for those
allocators. For example, on a machine with 4K pages, the database
may use ~50% more memory for the 0x2034 byte allocations.

Browsing through the source, it looks like the allocation set
implementation and the buffered file implementation both use
inline tags. The latter, at least, could be easily fixed by
allocating the buffer separately, but that would only be
worthwhile if the former were also modified.

Thoughts on this particular design decision?

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Clift 2003-08-28 10:05:27 Re: [HACKERS] 2-phase commit
Previous Message Ron Johnson 2003-08-28 09:02:36 Re: Hardware recommendations to scale to silly load