diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c new file mode 100644 index 8f467be..1a05666 *** a/src/backend/storage/lmgr/proc.c --- b/src/backend/storage/lmgr/proc.c *************** InitProcGlobal(void) *** 168,173 **** --- 168,177 ---- bool found; uint32 TotalProcs = MaxBackends + NUM_AUXILIARY_PROCS + max_prepared_xacts; + /* PGXACT should be aligned to the power of 2 */ + StaticAssertExpr((sizeof(PGXACT) & (sizeof(PGXACT) - 1)) == 0, + "PGXACT is not properly 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 5f38fa6..a7e0ea3 *** a/src/include/storage/proc.h --- b/src/include/storage/proc.h *************** extern PGDLLIMPORT struct PGXACT *MyPgXa *** 189,199 **** /* * 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 --- 189,208 ---- /* * 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. Thereby, it's desirable that writes of these fields ! * invalidate as less cache lines as possible. From that point of view, we ! * should prevent PGXACT from being on the boundary of cache lines. In order ! * to achieve that we align PGXACT to the nearest power of 2. That gives ! * considerable speedup on systems with many CPU cores. */ + + /* Calculation of padding for PGXACT. Update this after changing of PGXACT. */ + #define PGXACTPadSize (16 - 2 * sizeof(TransactionId) \ + - 2 * sizeof(uint8) - 2 * sizeof(bool)) + typedef struct PGXACT { TransactionId xid; /* id of top-level transaction currently being *************** typedef struct PGXACT *** 211,216 **** --- 220,227 ---- * previously called InCommit */ uint8 nxids; + + char pad[PGXACTPadSize]; } PGXACT; /*