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

Commit2d30675

Browse files
committed
Pad semaphores to avoid false sharing.
In a USE_UNNAMED_SEMAPHORES build, the default on Linux and FreeBSDsince commitecb0d20, we have an array of sem_t objects. Thisturned out to reduce performance compared to the previous defaultUSE_SYSV_SEMAPHORES on an 8 socket system. Testing showed that thelost performance could be regained by padding the array elements sothat they have their own cache lines. This matches what we do forsimilar hot arrays (see LWLockPadded, WALInsertLockPadded).Back-patch to 10, where unnamed semaphores were adopted as the defaultsemaphore interface on those operating systems.Author: Thomas MunroReviewed-by: Andres FreundReported-by: Mithun CyTested-by: Mithun Cy, Tom Lane, Thomas MunroDiscussion:https://postgr.es/m/CAD__OugYDM3O%2BdyZnnZSbJprSfsGFJcQ1R%3De59T3hcLmDug4_w%40mail.gmail.com
1 parent487bcc6 commit2d30675

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

‎src/backend/port/posix_sema.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,19 @@
4141
#error cannot use named POSIX semaphores with EXEC_BACKEND
4242
#endif
4343

44+
typedefunionSemTPadded
45+
{
46+
sem_tpgsem;
47+
charpad[PG_CACHE_LINE_SIZE];
48+
}SemTPadded;
49+
4450
/* typedef PGSemaphore is equivalent to pointer to sem_t */
4551
typedefstructPGSemaphoreData
4652
{
47-
sem_tpgsem;
53+
SemTPaddedsem_padded;
4854
}PGSemaphoreData;
4955

50-
#definePG_SEM_REF(x)(&(x)->pgsem)
56+
#definePG_SEM_REF(x)(&(x)->sem_padded.pgsem)
5157

5258
#defineIPCProtection(0600)/* access/modify by user only */
5359

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp