diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c new file mode 100644 index 1b836f7..3875687 *** a/src/backend/storage/lmgr/proc.c --- b/src/backend/storage/lmgr/proc.c *************** InitProcGlobal(void) *** 168,173 **** --- 168,176 ---- bool found; uint32 TotalProcs = MaxBackends + NUM_AUXILIARY_PROCS + max_prepared_xacts; + StaticAssertExpr(sizeof(PGXACT) == PG_CACHE_LINE_SIZE, + "PGXACT is not cacheline aligned"); + /* Create the ProcGlobal shared structure */ ProcGlobal = (PROC_HDR *) ShmemInitStruct("Proc Header", sizeof(PROC_HDR), &found); diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h new file mode 100644 index 398fa8a..7024369 *** a/src/include/storage/proc.h --- b/src/include/storage/proc.h *************** extern PGDLLIMPORT struct PGXACT *MyPgXa *** 187,197 **** /* * Prior to PostgreSQL 9.2, the fields below were stored as part of the * PGPROC. However, benchmarking revealed that packing these particular ! * members into a separate array as tightly as possible sped up GetSnapshotData ! * considerably on systems with many CPU cores, by reducing the number of ! * cache lines needing to be fetched. Thus, think very carefully before adding ! * anything else here. */ typedef struct PGXACT { TransactionId xid; /* id of top-level transaction currently being --- 187,204 ---- /* * Prior to PostgreSQL 9.2, the fields below were stored as part of the * PGPROC. However, benchmarking revealed that packing these particular ! * members into a separate array sped up GetSnapshotData considerably on ! * systems with many CPU cores, by reducing the number of cache lines needing ! * to be fetched. Also, this fields are subject of intensive writes even on ! * read-only workloads. This is why cache line alignment of them reduce cache ! * misses during GetSnapshotData and also gives considerable speedup on systems ! * with many CPU cores. */ + + /* Calculation of padding for PGXACT. Update this after changing of PGXACT. */ + #define PGXACTPadSize (PG_CACHE_LINE_SIZE - 2 * sizeof(TransactionId) \ + - 2 * sizeof(uint8) - 2 * sizeof(bool)) + typedef struct PGXACT { TransactionId xid; /* id of top-level transaction currently being *************** typedef struct PGXACT *** 209,214 **** --- 216,223 ---- * previously called InCommit */ uint8 nxids; + + char pad[PGXACTPadSize]; } PGXACT; /*