Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit73487a6

Browse files
committed
snapshot scalability: Move subxact info to ProcGlobal, remove PGXACT.
Similar to the previous changes this increases the chance that datafrequently needed by GetSnapshotData() stays in l2 cache. In manyworkloads subtransactions are very rare, and this makes the check forthat considerably cheaper.As this removes the last member of PGXACT, there is no need to keep itaround anymore.On a larger 2 socket machine this and the two preceding commits resultin a ~1.07x performance increase in read-only pgbench. For read-heavymixed r/w workloads without row level contention, I see about 1.1x.Author: Andres Freund <andres@anarazel.de>Reviewed-By: Robert Haas <robertmhaas@gmail.com>Reviewed-By: Thomas Munro <thomas.munro@gmail.com>Reviewed-By: David Rowley <dgrowleyml@gmail.com>Discussion:https://postgr.es/m/20200301083601.ews6hz5dduc3w2se@alap3.anarazel.de
1 parent5788e25 commit73487a6

File tree

7 files changed

+113
-113
lines changed

7 files changed

+113
-113
lines changed

‎src/backend/access/transam/clog.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ TransactionIdSetPageStatus(TransactionId xid, int nsubxids,
295295
*/
296296
if (all_xact_same_page&&xid==MyProc->xid&&
297297
nsubxids <=THRESHOLD_SUBTRANS_CLOG_OPT&&
298-
nsubxids==MyPgXact->nxids&&
298+
nsubxids==MyProc->subxidStatus.count&&
299299
memcmp(subxids,MyProc->subxids.xids,
300300
nsubxids*sizeof(TransactionId))==0)
301301
{
@@ -510,16 +510,15 @@ TransactionGroupUpdateXidStatus(TransactionId xid, XidStatus status,
510510
while (nextidx!=INVALID_PGPROCNO)
511511
{
512512
PGPROC*proc=&ProcGlobal->allProcs[nextidx];
513-
PGXACT*pgxact=&ProcGlobal->allPgXact[nextidx];
514513

515514
/*
516515
* Transactions with more than THRESHOLD_SUBTRANS_CLOG_OPT sub-XIDs
517516
* should not use group XID status update mechanism.
518517
*/
519-
Assert(pgxact->nxids <=THRESHOLD_SUBTRANS_CLOG_OPT);
518+
Assert(proc->subxidStatus.count <=THRESHOLD_SUBTRANS_CLOG_OPT);
520519

521520
TransactionIdSetPageStatusInternal(proc->clogGroupMemberXid,
522-
pgxact->nxids,
521+
proc->subxidStatus.count,
523522
proc->subxids.xids,
524523
proc->clogGroupMemberXidStatus,
525524
proc->clogGroupMemberLsn,

‎src/backend/access/transam/twophase.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
*GIDs and aborts the transaction if there already is a global
2222
*transaction in prepared state with the same GID.
2323
*
24-
*A global transaction (gxact) also has dummyPGXACT andPGPROC; this is
25-
*what keepsthe XID considered running by TransactionIdIsInProgress.
26-
*It is alsoconvenient as a PGPROC to hook the gxact's locks to.
24+
*A global transaction (gxact) also has dummy PGPROC; this is what keeps
25+
*the XID considered running by TransactionIdIsInProgress. It is also
26+
*convenient as a PGPROC to hook the gxact's locks to.
2727
*
2828
*Information to recover prepared transactions in case of crash is
2929
*now stored in WAL for the common case. In some cases there will be
@@ -447,14 +447,12 @@ MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid,
447447
TimestampTzprepared_at,Oidowner,Oiddatabaseid)
448448
{
449449
PGPROC*proc;
450-
PGXACT*pgxact;
451450
inti;
452451

453452
Assert(LWLockHeldByMeInMode(TwoPhaseStateLock,LW_EXCLUSIVE));
454453

455454
Assert(gxact!=NULL);
456455
proc=&ProcGlobal->allProcs[gxact->pgprocno];
457-
pgxact=&ProcGlobal->allPgXact[gxact->pgprocno];
458456

459457
/* Initialize the PGPROC entry */
460458
MemSet(proc,0,sizeof(PGPROC));
@@ -480,8 +478,8 @@ MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid,
480478
for (i=0;i<NUM_LOCK_PARTITIONS;i++)
481479
SHMQueueInit(&(proc->myProcLocks[i]));
482480
/* subxid data must be filled later by GXactLoadSubxactData */
483-
pgxact->overflowed= false;
484-
pgxact->nxids=0;
481+
proc->subxidStatus.overflowed= false;
482+
proc->subxidStatus.count=0;
485483

486484
gxact->prepared_at=prepared_at;
487485
gxact->xid=xid;
@@ -510,19 +508,18 @@ GXactLoadSubxactData(GlobalTransaction gxact, int nsubxacts,
510508
TransactionId*children)
511509
{
512510
PGPROC*proc=&ProcGlobal->allProcs[gxact->pgprocno];
513-
PGXACT*pgxact=&ProcGlobal->allPgXact[gxact->pgprocno];
514511

515512
/* We need no extra lock since the GXACT isn't valid yet */
516513
if (nsubxacts>PGPROC_MAX_CACHED_SUBXIDS)
517514
{
518-
pgxact->overflowed= true;
515+
proc->subxidStatus.overflowed= true;
519516
nsubxacts=PGPROC_MAX_CACHED_SUBXIDS;
520517
}
521518
if (nsubxacts>0)
522519
{
523520
memcpy(proc->subxids.xids,children,
524521
nsubxacts*sizeof(TransactionId));
525-
pgxact->nxids=nsubxacts;
522+
proc->subxidStatus.count=nsubxacts;
526523
}
527524
}
528525

‎src/backend/access/transam/varsup.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,22 +222,31 @@ GetNewTransactionId(bool isSubXact)
222222
*/
223223
if (!isSubXact)
224224
{
225+
Assert(ProcGlobal->subxidStates[MyProc->pgxactoff].count==0);
226+
Assert(!ProcGlobal->subxidStates[MyProc->pgxactoff].overflowed);
227+
Assert(MyProc->subxidStatus.count==0);
228+
Assert(!MyProc->subxidStatus.overflowed);
229+
225230
/* LWLockRelease acts as barrier */
226231
MyProc->xid=xid;
227232
ProcGlobal->xids[MyProc->pgxactoff]=xid;
228233
}
229234
else
230235
{
231-
intnxids=MyPgXact->nxids;
236+
XidCacheStatus*substat=&ProcGlobal->subxidStates[MyProc->pgxactoff];
237+
intnxids=MyProc->subxidStatus.count;
238+
239+
Assert(substat->count==MyProc->subxidStatus.count);
240+
Assert(substat->overflowed==MyProc->subxidStatus.overflowed);
232241

233242
if (nxids<PGPROC_MAX_CACHED_SUBXIDS)
234243
{
235244
MyProc->subxids.xids[nxids]=xid;
236245
pg_write_barrier();
237-
MyPgXact->nxids=nxids+1;
246+
MyProc->subxidStatus.count=substat->count=nxids+1;
238247
}
239248
else
240-
MyPgXact->overflowed= true;
249+
MyProc->subxidStatus.overflowed=substat->overflowed= true;
241250
}
242251

243252
LWLockRelease(XidGenLock);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp