summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorAndres Freund2015-01-29 16:49:03 +0000
committerAndres Freund2015-01-29 21:48:45 +0000
commited127002d8c592610bc8e716759a1a70657483b6 (patch)
tree73ce1d9c835b4816f66f73884aed857635b44d71 /contrib
parent7142bfbbd34a1dbe34346534d7479915145352b3 (diff)
Align buffer descriptors to cache line boundaries.
Benchmarks has shown that aligning the buffer descriptor array to cache lines is important for scalability; especially on bigger, multi-socket, machines. Currently the array sometimes already happens to be aligned by happenstance, depending how large previous shared memory allocations were. That can lead to wildly varying performance results after minor configuration changes. In addition to aligning the start of descriptor array, also force the size of individual descriptors to be of a common cache line size (64 bytes). That happens to already be the case on 64bit platforms, but this way we can change the struct BufferDesc more easily. As the alignment primarily matters in highly concurrent workloads which probably all are 64bit these days, and the space wastage of element alignment would be a bit more noticeable on 32bit systems, we don't force the stride to be cacheline sized on 32bit platforms for now. If somebody does actual performance testing, we can reevaluate that decision by changing the definition of BUFFERDESC_PADDED_SIZE. Discussion: 20140202151319.GD32123@awork2.anarazel.de Per discussion with Bruce Momjan, Tom Lane, Robert Haas, and Peter Geoghegan.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/pg_buffercache/pg_buffercache_pages.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/contrib/pg_buffercache/pg_buffercache_pages.c b/contrib/pg_buffercache/pg_buffercache_pages.c
index d00f9859088..98016fc365e 100644
--- a/contrib/pg_buffercache/pg_buffercache_pages.c
+++ b/contrib/pg_buffercache/pg_buffercache_pages.c
@@ -73,7 +73,6 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
if (SRF_IS_FIRSTCALL())
{
int i;
- volatile BufferDesc *bufHdr;
funcctx = SRF_FIRSTCALL_INIT();
@@ -146,8 +145,11 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
* Scan though all the buffers, saving the relevant fields in the
* fctx->record structure.
*/
- for (i = 0, bufHdr = BufferDescriptors; i < NBuffers; i++, bufHdr++)
+ for (i = 0; i < NBuffers; i++)
{
+ volatile BufferDesc *bufHdr;
+
+ bufHdr = GetBufferDescriptor(i);
/* Lock each buffer header before inspecting. */
LockBufHdr(bufHdr);