From 83481187f6e2f8c177bc85c522917d64e1b78b4b Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Tue, 10 Feb 2026 18:53:31 +0200 Subject: [PATCH v2 1/4] Align PGPROC to cache line boundary --- src/include/storage/proc.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index ac0df4aeaaa..53acce8a5a1 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -182,7 +182,7 @@ typedef enum * * See PROC_HDR for details. */ -struct PGPROC +typedef struct PGPROC { dlist_node links; /* list link if process is in a list */ dlist_head *procgloballist; /* procglobal list that owns this PGPROC */ @@ -337,10 +337,18 @@ struct PGPROC PGPROC *lockGroupLeader; /* lock group leader, if I'm a member */ dlist_head lockGroupMembers; /* list of members, if I'm a leader */ dlist_node lockGroupLink; /* my member link, if I'm a member */ -}; - -/* NOTE: "typedef struct PGPROC PGPROC" appears in storage/lock.h. */ +} +/* + * If compiler understands aligned pragma, use it to align the struct at cache + * line boundaries. This is just for performance, to (a) avoid false sharing + * and (b) to make the multiplication / division to convert between PGPROC * + * and ProcNumber be a little cheaper. + */ +#if defined(pg_attribute_aligned) + pg_attribute_aligned(PG_CACHE_LINE_SIZE) +#endif +PGPROC; extern PGDLLIMPORT PGPROC *MyProc; -- 2.47.3