mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +03:00
snapshot scalability: Move delayChkpt from PGXACT to PGPROC.
The goal of separating hotly accessed per-backend data from PGPROC into PGXACT is to make accesses fast (GetSnapshotData() in particular). But delayChkpt is not actually accessed frequently; only when starting a checkpoint. As it is frequently modified (multiple times in the course of a single transaction), storing it in the same cacheline as hotly accessed data unnecessarily dirties a contended cacheline. Therefore move delayChkpt to PGPROC. This is part of a larger series of patches intending to improve GetSnapshotData() scalability. It is committed and pushed separately, as it is independently beneficial (small but measurable win, limited by the other frequent modifications of PGXACT). Author: Andres Freund Reviewed-By: Robert Haas, Thomas Munro, David Rowley Discussion: https://postgr.es/m/20200301083601.ews6hz5dduc3w2se@alap3.anarazel.de
This commit is contained in:
@@ -3058,8 +3058,8 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
|
||||
* crash/basebackup, even though the state of the data directory would
|
||||
* require it.
|
||||
*/
|
||||
Assert(!MyPgXact->delayChkpt);
|
||||
MyPgXact->delayChkpt = true;
|
||||
Assert(!MyProc->delayChkpt);
|
||||
MyProc->delayChkpt = true;
|
||||
|
||||
/* WAL log truncation */
|
||||
WriteMTruncateXlogRec(newOldestMultiDB,
|
||||
@@ -3085,7 +3085,7 @@ TruncateMultiXact(MultiXactId newOldestMulti, Oid newOldestMultiDB)
|
||||
/* Then offsets */
|
||||
PerformOffsetsTruncation(oldestMulti, newOldestMulti);
|
||||
|
||||
MyPgXact->delayChkpt = false;
|
||||
MyProc->delayChkpt = false;
|
||||
|
||||
END_CRIT_SECTION();
|
||||
LWLockRelease(MultiXactTruncationLock);
|
||||
|
@@ -465,7 +465,7 @@ MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid,
|
||||
proc->lxid = (LocalTransactionId) xid;
|
||||
pgxact->xid = xid;
|
||||
pgxact->xmin = InvalidTransactionId;
|
||||
pgxact->delayChkpt = false;
|
||||
proc->delayChkpt = false;
|
||||
pgxact->vacuumFlags = 0;
|
||||
proc->pid = 0;
|
||||
proc->backendId = InvalidBackendId;
|
||||
@@ -1114,7 +1114,7 @@ EndPrepare(GlobalTransaction gxact)
|
||||
|
||||
START_CRIT_SECTION();
|
||||
|
||||
MyPgXact->delayChkpt = true;
|
||||
MyProc->delayChkpt = true;
|
||||
|
||||
XLogBeginInsert();
|
||||
for (record = records.head; record != NULL; record = record->next)
|
||||
@@ -1157,7 +1157,7 @@ EndPrepare(GlobalTransaction gxact)
|
||||
* checkpoint starting after this will certainly see the gxact as a
|
||||
* candidate for fsyncing.
|
||||
*/
|
||||
MyPgXact->delayChkpt = false;
|
||||
MyProc->delayChkpt = false;
|
||||
|
||||
/*
|
||||
* Remember that we have this GlobalTransaction entry locked for us. If
|
||||
@@ -2204,7 +2204,7 @@ RecordTransactionCommitPrepared(TransactionId xid,
|
||||
START_CRIT_SECTION();
|
||||
|
||||
/* See notes in RecordTransactionCommit */
|
||||
MyPgXact->delayChkpt = true;
|
||||
MyProc->delayChkpt = true;
|
||||
|
||||
/*
|
||||
* Emit the XLOG commit record. Note that we mark 2PC commits as
|
||||
@@ -2252,7 +2252,7 @@ RecordTransactionCommitPrepared(TransactionId xid,
|
||||
TransactionIdCommitTree(xid, nchildren, children);
|
||||
|
||||
/* Checkpoint can proceed now */
|
||||
MyPgXact->delayChkpt = false;
|
||||
MyProc->delayChkpt = false;
|
||||
|
||||
END_CRIT_SECTION();
|
||||
|
||||
|
@@ -1307,7 +1307,7 @@ RecordTransactionCommit(void)
|
||||
* a bit fuzzy, but it doesn't matter.
|
||||
*/
|
||||
START_CRIT_SECTION();
|
||||
MyPgXact->delayChkpt = true;
|
||||
MyProc->delayChkpt = true;
|
||||
|
||||
SetCurrentTransactionStopTimestamp();
|
||||
|
||||
@@ -1408,7 +1408,7 @@ RecordTransactionCommit(void)
|
||||
*/
|
||||
if (markXidCommitted)
|
||||
{
|
||||
MyPgXact->delayChkpt = false;
|
||||
MyProc->delayChkpt = false;
|
||||
END_CRIT_SECTION();
|
||||
}
|
||||
|
||||
|
@@ -904,7 +904,7 @@ XLogSaveBufferForHint(Buffer buffer, bool buffer_std)
|
||||
/*
|
||||
* Ensure no checkpoint can change our view of RedoRecPtr.
|
||||
*/
|
||||
Assert(MyPgXact->delayChkpt);
|
||||
Assert(MyProc->delayChkpt);
|
||||
|
||||
/*
|
||||
* Update RedoRecPtr so that we can make the right decision
|
||||
|
Reference in New Issue
Block a user