From ce1218929f2e14106c0c1160bfa941ffe0b6b745 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Fri, 20 Feb 2026 22:58:40 +0200 Subject: [PATCH v2 2/2] Align PGPROC to cache line boundary On common architectures, the PGPROC happened to be a multiple of 64 bytes on PG 18, but it's changed on 'master' since. There was worry that changing the alignment might hurt performance, due to false cacheline sharing across PGPROC elements. However, there was no explicit alignment, so any alignment to cache lines was accidental. Add explicit alignment to remove worry about false sharing. Reviewed-by: Bertrand Drouvot Discussion: https://www.postgresql.org/message-id/3dd6f70c-b94d-4428-8e75-74a7136396be@iki.fi --- src/include/storage/proc.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index b2fd4d02959..a8d2e7db1a1 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -374,8 +374,16 @@ typedef struct PGPROC ************************************************************************/ uint32 wait_event_info; /* proc's wait information */ -} PGPROC; +} +/* + * If compiler understands aligned pragma, use it to align the struct at cache + * line boundaries. This is just for performance, to avoid false sharing. + */ +#if defined(pg_attribute_aligned) + pg_attribute_aligned(PG_CACHE_LINE_SIZE) +#endif +PGPROC; extern PGDLLIMPORT PGPROC *MyProc; -- 2.47.3