File tree Expand file tree Collapse file tree 3 files changed +24
-6
lines changed Expand file tree Collapse file tree 3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change 88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.70 2003/08/04 02:40:03 momjian Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.71 2003/09/21 17:57:21 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -131,6 +131,7 @@ InitShmemAllocation(void *seghdr)
131131void *
132132ShmemAlloc (Size size )
133133{
134+ uint32 newStart ;
134135 uint32 newFree ;
135136 void * newSpace ;
136137
@@ -146,10 +147,16 @@ ShmemAlloc(Size size)
146147
147148 SpinLockAcquire (ShmemLock );
148149
149- newFree = shmemseghdr -> freeoffset + size ;
150+ newStart = shmemseghdr -> freeoffset ;
151+
152+ /* extra alignment for large requests, since they are probably buffers */
153+ if (size >= BLCKSZ )
154+ newStart = BUFFERALIGN (newStart );
155+
156+ newFree = newStart + size ;
150157 if (newFree <= shmemseghdr -> totalsize )
151158 {
152- newSpace = (void * ) MAKE_PTR (shmemseghdr -> freeoffset );
159+ newSpace = (void * ) MAKE_PTR (newStart );
153160 shmemseghdr -> freeoffset = newFree ;
154161 }
155162 else
Original file line number Diff line number Diff line change 1212 * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
1313 * Portions Copyright (c) 1994, Regents of the University of California
1414 *
15- * $Id: c.h,v 1.152 2003/08/04 02:40:10 momjian Exp $
15+ * $Id: c.h,v 1.153 2003/09/21 17:57:21 tgl Exp $
1616 *
1717 *-------------------------------------------------------------------------
1818 */
@@ -522,13 +522,16 @@ typedef NameData *Name;
522522 * ----------------
523523 */
524524
525- #define TYPEALIGN (ALIGNVAL ,LEN ) (((long)(LEN) + (ALIGNVAL-1)) & ~(ALIGNVAL-1))
525+ #define TYPEALIGN (ALIGNVAL ,LEN ) \
526+ (((long) (LEN) + (ALIGNVAL-1)) & ~((long) (ALIGNVAL-1)))
526527
527528#define SHORTALIGN (LEN ) TYPEALIGN(ALIGNOF_SHORT, (LEN))
528529#define INTALIGN (LEN ) TYPEALIGN(ALIGNOF_INT, (LEN))
529530#define LONGALIGN (LEN ) TYPEALIGN(ALIGNOF_LONG, (LEN))
530531#define DOUBLEALIGN (LEN ) TYPEALIGN(ALIGNOF_DOUBLE, (LEN))
531532#define MAXALIGN (LEN ) TYPEALIGN(MAXIMUM_ALIGNOF, (LEN))
533+ /* MAXALIGN covers only built-in types, not buffers */
534+ #define BUFFERALIGN (LEN ) TYPEALIGN(ALIGNOF_BUFFER, (LEN))
532535
533536
534537/* ----------------------------------------------------------------
Original file line number Diff line number Diff line change 66 * for developers. If you edit any of these, be sure to do a *full*
77 * rebuild (and an initdb if noted).
88 *
9- * $Id: pg_config_manual.h,v 1.5 2003/08/04 00:43:29 momjian Exp $
9+ * $Id: pg_config_manual.h,v 1.6 2003/09/21 17:57:21 tgl Exp $
1010 *------------------------------------------------------------------------
1111 */
1212
126126 */
127127#define BITS_PER_BYTE 8
128128
129+ /*
130+ * Preferred alignment for disk I/O buffers. On some CPUs, copies between
131+ * user space and kernel space are significantly faster if the user buffer
132+ * is aligned on a larger-than-MAXALIGN boundary. Ideally this should be
133+ * a platform-dependent value, but for now we just hard-wire it.
134+ */
135+ #define ALIGNOF_BUFFER 32
136+
129137/*
130138 * Disable UNIX sockets for those operating system.
131139 */
You can’t perform that action at this time.
0 commit comments