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

Commit6897f0e

Browse files
committed
Optimize memory access in GetRunningTransactionData()
e85662d made GetRunningTransactionData() calculate the oldest runningtransaction id within the current database. This commit optimized thiscalculation by performing a cheap transaction id comparison before fetchingthe process database id, while the latter could cause extra cache misses.Reported-by: Noah MischDiscussion:https://postgr.es/m/20240630231816.bf.nmisch%40google.com
1 parent6c1af54 commit6897f0e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

‎src/backend/storage/ipc/procarray.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2753,8 +2753,6 @@ GetRunningTransactionData(void)
27532753
*/
27542754
for (index=0;index<arrayP->numProcs;index++)
27552755
{
2756-
intpgprocno=arrayP->pgprocnos[index];
2757-
PGPROC*proc=&allProcs[pgprocno];
27582756
TransactionIdxid;
27592757

27602758
/* Fetch xid just once - see GetNewTransactionId */
@@ -2776,11 +2774,18 @@ GetRunningTransactionData(void)
27762774
oldestRunningXid=xid;
27772775

27782776
/*
2779-
* Also, update the oldest running xid within the current database.
2777+
* Also, update the oldest running xid within the current database. As
2778+
* fetching pgprocno and PGPROC could cause cache misses, we do cheap
2779+
* TransactionId comparison first.
27802780
*/
2781-
if (proc->databaseId==MyDatabaseId&&
2782-
TransactionIdPrecedes(xid,oldestDatabaseRunningXid))
2783-
oldestDatabaseRunningXid=xid;
2781+
if (TransactionIdPrecedes(xid,oldestDatabaseRunningXid))
2782+
{
2783+
intpgprocno=arrayP->pgprocnos[index];
2784+
PGPROC*proc=&allProcs[pgprocno];
2785+
2786+
if (proc->databaseId==MyDatabaseId)
2787+
oldestDatabaseRunningXid=xid;
2788+
}
27842789

27852790
if (ProcGlobal->subxidStates[index].overflowed)
27862791
suboverflowed= true;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp