0003-XXX-Hack-ShmemAlloc-to-align-all-allocations-to-cach.patch

text/x-patch

Filename: 0003-XXX-Hack-ShmemAlloc-to-align-all-allocations-to-cach.patch
Type: text/x-patch
Part: 2
Message: Re: better atomics - v0.6

Patch

Format: unified
Series: patch 0003
File+
src/backend/storage/ipc/shmem.c 2 2
src/include/pg_config_manual.h 1 1
>From 304d6ff56f53e586e161dde9d62789facce74853 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Tue, 4 Feb 2014 13:34:34 +0100
Subject: [PATCH 3/5] XXX: Hack ShmemAlloc() to align all allocations to
 cacheline boundaries

---
 src/backend/storage/ipc/shmem.c | 4 ++--
 src/include/pg_config_manual.h  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c
index 2ea2216..193b6dc 100644
--- a/src/backend/storage/ipc/shmem.c
+++ b/src/backend/storage/ipc/shmem.c
@@ -184,8 +184,8 @@ ShmemAlloc(Size size)
 
 	newStart = shmemseghdr->freeoffset;
 
-	/* extra alignment for large requests, since they are probably buffers */
-	if (size >= BLCKSZ)
+	/* align all request to cacheline boundaries */
+	if (size >= BUFSIZ)
 		newStart = BUFFERALIGN(newStart);
 
 	newFree = newStart + size;
diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
index 4bc591a..6576956 100644
--- a/src/include/pg_config_manual.h
+++ b/src/include/pg_config_manual.h
@@ -123,7 +123,7 @@
  * is aligned on a larger-than-MAXALIGN boundary.  Ideally this should be
  * a platform-dependent value, but for now we just hard-wire it.
  */
-#define ALIGNOF_BUFFER	32
+#define ALIGNOF_BUFFER	64
 
 /*
  * Disable UNIX sockets for certain operating systems.
-- 
2.0.0.rc2.4.g1dc51c6.dirty