Re: Memory buffer alignment

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Manfred Spraul <manfred(at)colorfullife(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Memory buffer alignment
Date: 2003-09-27 21:08:38
Message-ID: 200309272108.h8RL8co10477@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


I found this very interested, and realize we have shared buffers aligned
at 8-bytes in CVS.

However, I know if I allocate an 8k block, it will usually be aligned on
an 8k boundary, right? I know the i386 uses 4k memory pages, and it
certainly seems like it would be a good idea to have the 8k buffers
aligned on 4k offsets.

Can someone run some tests to find out if there is any value to doing 4k
offsets for shared buffer pages? I am also interested to see if any
speed improvement can be seen with a MAXIMUM_ALIGNOF to 8.

---------------------------------------------------------------------------

Tom Lane wrote:
> Manfred Spraul <manfred(at)colorfullife(dot)com> writes:
> > Unfortunately it's the slower one: Intel cpus have a microcode fastpath
> > for memcopies that are 8-byte aligned. This fastpath is around 50%
> > faster than the manual copy that is used for "misaligned" (i.e. only
> > 4-byte aligned) pointers.
>
> Maybe it'd be worth setting MAXIMUM_ALIGNOF to 8 on such CPUs? Or at
> least hacking ShmemAlloc and friends to use 8-byte alignment. I assume
> the major issue here is that the shared buffers don't get 8-byte-aligned
> within the shared memory segment.
>
> Are there any machines where it'd be worth forcing an even larger
> alignment for the buffers?
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-09-27 21:13:30 Re: Memory buffer alignment
Previous Message Tom Lane 2003-09-27 20:49:29 Re: PostgreSQL 7.4beta3 does not compile on AIX 5 ...