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

Commit14ff44f

Browse files
committed
Used optimized linear search in more code paths
This commit updates two code paths to use pg_lfind32() introduced byb6ef167 with TransactionId arrays:- At the end of TransactionIdIsInProgress(), when checking for the caseof still running but overflowed subxids.- XidIsConcurrent(), when checking for a serializable conflict.These cases are less impactful than37a6e5d, but a bit ofmicro-benchmarking of this API shows that linear search speeds up by~20% depending on the number of items involved (x86_64 and amd64 lookedat here).Author: Nathan BossartReviewed-by: Richard Guo, Michael PaquierDiscussion:https://postgr.es/m/20220901185153.GA783106@nathanxps13
1 parent9a69152 commit14ff44f

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#include"commands/dbcommands.h"
5959
#include"miscadmin.h"
6060
#include"pgstat.h"
61+
#include"port/pg_lfind.h"
6162
#include"storage/proc.h"
6263
#include"storage/procarray.h"
6364
#include"storage/spin.h"
@@ -1586,14 +1587,9 @@ TransactionIdIsInProgress(TransactionId xid)
15861587
*/
15871588
topxid=SubTransGetTopmostTransaction(xid);
15881589
Assert(TransactionIdIsValid(topxid));
1589-
if (!TransactionIdEquals(topxid,xid))
1590-
{
1591-
for (inti=0;i<nxids;i++)
1592-
{
1593-
if (TransactionIdEquals(xids[i],topxid))
1594-
return true;
1595-
}
1596-
}
1590+
if (!TransactionIdEquals(topxid,xid)&&
1591+
pg_lfind32(topxid,xids,nxids))
1592+
return true;
15971593

15981594
cachedXidIsNotInProgress=xid;
15991595
return false;

‎src/backend/storage/lmgr/predicate.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
#include"access/xlog.h"
203203
#include"miscadmin.h"
204204
#include"pgstat.h"
205+
#include"port/pg_lfind.h"
205206
#include"storage/bufmgr.h"
206207
#include"storage/predicate.h"
207208
#include"storage/predicate_internals.h"
@@ -4065,7 +4066,6 @@ static bool
40654066
XidIsConcurrent(TransactionIdxid)
40664067
{
40674068
Snapshotsnap;
4068-
uint32i;
40694069

40704070
Assert(TransactionIdIsValid(xid));
40714071
Assert(!TransactionIdEquals(xid,GetTopTransactionIdIfAny()));
@@ -4078,13 +4078,7 @@ XidIsConcurrent(TransactionId xid)
40784078
if (TransactionIdFollowsOrEquals(xid,snap->xmax))
40794079
return true;
40804080

4081-
for (i=0;i<snap->xcnt;i++)
4082-
{
4083-
if (xid==snap->xip[i])
4084-
return true;
4085-
}
4086-
4087-
return false;
4081+
returnpg_lfind32(xid,snap->xip,snap->xcnt);
40884082
}
40894083

40904084
bool

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp