Memory buffer alignment - Mailing list pgsql-hackers

From Manfred Spraul
Subject Memory buffer alignment
Date
Msg-id 3F6A2319.8040203@colorfullife.com
Whole thread Raw
Responses Re: Memory buffer alignment
List pgsql-hackers
Hi,

When analyzing the kernel profile from osdl dbt benchmarks, I noticed 
that around 50% of the kernel time is spent in __copy_user_intel.
http://khack.osdl.org/stp/280060/profile/

This function is one of two functions that does the actual memory copy 
from/to kernel space to/from user space.
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. I don't know enough about other cpus, but I'd 
expect that most cpus prefer well-aligned buffers.
How are the user space buffers allocated?
So far I found buffile.c, but "struct BufFile.buffer" is at offset 32, 
i.e. aligned, although by chance. What is the alignment of the output of 
palloc? Is buffile.c the main code that reads/writes data to disk?

--   Manfred



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: 7.4beta2 vs 7.3.3
Next
From: Carlos Guzman Alvarez
Date:
Subject: Array Parameters on protocol 3.0