mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Move "hot" members of PGPROC into a separate PGXACT array.
This speeds up snapshot-taking and reduces ProcArrayLock contention. Also, the PGPROC (and PGXACT) structures used by two-phase commit are now allocated as part of the main array, rather than in a separate array, and we keep ProcArray sorted in pointer order. These changes are intended to minimize the number of cache lines that must be pulled in to take a snapshot, and testing shows a substantial increase in performance on both read and write workloads at high concurrencies. Pavan Deolasee, Heikki Linnakangas, Robert Haas
This commit is contained in:
@ -54,7 +54,7 @@ GetNewTransactionId(bool isSubXact)
|
||||
if (IsBootstrapProcessingMode())
|
||||
{
|
||||
Assert(!isSubXact);
|
||||
MyProc->xid = BootstrapTransactionId;
|
||||
MyPgXact->xid = BootstrapTransactionId;
|
||||
return BootstrapTransactionId;
|
||||
}
|
||||
|
||||
@ -208,20 +208,21 @@ GetNewTransactionId(bool isSubXact)
|
||||
* TransactionId and int fetch/store are atomic.
|
||||
*/
|
||||
volatile PGPROC *myproc = MyProc;
|
||||
volatile PGXACT *mypgxact = MyPgXact;
|
||||
|
||||
if (!isSubXact)
|
||||
myproc->xid = xid;
|
||||
mypgxact->xid = xid;
|
||||
else
|
||||
{
|
||||
int nxids = myproc->subxids.nxids;
|
||||
int nxids = mypgxact->nxids;
|
||||
|
||||
if (nxids < PGPROC_MAX_CACHED_SUBXIDS)
|
||||
{
|
||||
myproc->subxids.xids[nxids] = xid;
|
||||
myproc->subxids.nxids = nxids + 1;
|
||||
mypgxact->nxids = nxids + 1;
|
||||
}
|
||||
else
|
||||
myproc->subxids.overflowed = true;
|
||||
mypgxact->overflowed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user