Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5aa29e8

Browse files
committed
Arrange to align shared disk buffers on at least 32-byte boundaries,
not just MAXALIGN boundaries. This makes a noticeable difference inthe speed of transfers to and from kernel space, at least on recentPentiums, and might help other CPUs too. We should look at makingthis happen for local buffers and buffile.c too. Patch from Manfred Spraul.
1 parent11b274f commit5aa29e8

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

‎src/backend/storage/ipc/shmem.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
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)
131131
void*
132132
ShmemAlloc(Sizesize)
133133
{
134+
uint32newStart;
134135
uint32newFree;
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

‎src/include/c.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
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-
#defineTYPEALIGN(ALIGNVAL,LEN) (((long)(LEN) + (ALIGNVAL-1)) & ~(ALIGNVAL-1))
525+
#defineTYPEALIGN(ALIGNVAL,LEN) \
526+
(((long) (LEN) + (ALIGNVAL-1)) & ~((long) (ALIGNVAL-1)))
526527

527528
#defineSHORTALIGN(LEN)TYPEALIGN(ALIGNOF_SHORT, (LEN))
528529
#defineINTALIGN(LEN)TYPEALIGN(ALIGNOF_INT, (LEN))
529530
#defineLONGALIGN(LEN)TYPEALIGN(ALIGNOF_LONG, (LEN))
530531
#defineDOUBLEALIGN(LEN)TYPEALIGN(ALIGNOF_DOUBLE, (LEN))
531532
#defineMAXALIGN(LEN)TYPEALIGN(MAXIMUM_ALIGNOF, (LEN))
533+
/* MAXALIGN covers only built-in types, not buffers */
534+
#defineBUFFERALIGN(LEN)TYPEALIGN(ALIGNOF_BUFFER, (LEN))
532535

533536

534537
/* ----------------------------------------------------------------

‎src/include/pg_config_manual.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
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

@@ -126,6 +126,14 @@
126126
*/
127127
#defineBITS_PER_BYTE8
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+
#defineALIGNOF_BUFFER32
136+
129137
/*
130138
* Disable UNIX sockets for those operating system.
131139
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp