File tree 3 files changed +24
-6
lines changed
3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change 8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -131,6 +131,7 @@ InitShmemAllocation(void *seghdr)
131
131
void *
132
132
ShmemAlloc (Size size )
133
133
{
134
+ uint32 newStart ;
134
135
uint32 newFree ;
135
136
void * newSpace ;
136
137
@@ -146,10 +147,16 @@ ShmemAlloc(Size size)
146
147
147
148
SpinLockAcquire (ShmemLock );
148
149
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 ;
150
157
if (newFree <= shmemseghdr -> totalsize )
151
158
{
152
- newSpace = (void * ) MAKE_PTR (shmemseghdr -> freeoffset );
159
+ newSpace = (void * ) MAKE_PTR (newStart );
153
160
shmemseghdr -> freeoffset = newFree ;
154
161
}
155
162
else
Original file line number Diff line number Diff line change 12
12
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
13
13
* Portions Copyright (c) 1994, Regents of the University of California
14
14
*
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 $
16
16
*
17
17
*-------------------------------------------------------------------------
18
18
*/
@@ -522,13 +522,16 @@ typedef NameData *Name;
522
522
* ----------------
523
523
*/
524
524
525
- #define TYPEALIGN (ALIGNVAL ,LEN ) (((long)(LEN) + (ALIGNVAL-1)) & ~(ALIGNVAL-1))
525
+ #define TYPEALIGN (ALIGNVAL ,LEN ) \
526
+ (((long) (LEN) + (ALIGNVAL-1)) & ~((long) (ALIGNVAL-1)))
526
527
527
528
#define SHORTALIGN (LEN ) TYPEALIGN(ALIGNOF_SHORT, (LEN))
528
529
#define INTALIGN (LEN ) TYPEALIGN(ALIGNOF_INT, (LEN))
529
530
#define LONGALIGN (LEN ) TYPEALIGN(ALIGNOF_LONG, (LEN))
530
531
#define DOUBLEALIGN (LEN ) TYPEALIGN(ALIGNOF_DOUBLE, (LEN))
531
532
#define MAXALIGN (LEN ) TYPEALIGN(MAXIMUM_ALIGNOF, (LEN))
533
+ /* MAXALIGN covers only built-in types, not buffers */
534
+ #define BUFFERALIGN (LEN ) TYPEALIGN(ALIGNOF_BUFFER, (LEN))
532
535
533
536
534
537
/* ----------------------------------------------------------------
Original file line number Diff line number Diff line change 6
6
* for developers. If you edit any of these, be sure to do a *full*
7
7
* rebuild (and an initdb if noted).
8
8
*
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 $
10
10
*------------------------------------------------------------------------
11
11
*/
12
12
126
126
*/
127
127
#define BITS_PER_BYTE 8
128
128
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
+
129
137
/*
130
138
* Disable UNIX sockets for those operating system.
131
139
*/
You can’t perform that action at this time.
0 commit comments