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

Commit6bad580

Browse files
Avoid SnapshotResetXmin() during AtEOXact_Snapshot()
For normal commits and aborts we already reset PgXact->xmin,so we can simply avoid running SnapshotResetXmin() twice.During performance tests by Alexander Korotkov, diagnosisby Andres Freund showed PgXact array as a bottleneck. Aftermanual analysis by me of the code paths that touch thosememory locations, I was able to identify extraneous codein the main transaction commit path.Avoiding touching highly contented shmem improves concurrentperformance slightly on all workloads, confirmed by testsrun by Ashutosh Sharma and Alexander Korotkov.Simon RiggsDiscussion: CANP8+jJdXE9b+b9F8CQT-LuxxO0PBCB-SZFfMVAdp+akqo4zfg@mail.gmail.com
1 parentfd01983 commit6bad580

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,7 +2137,7 @@ CommitTransaction(void)
21372137
AtEOXact_ComboCid();
21382138
AtEOXact_HashTables(true);
21392139
AtEOXact_PgStat(true);
2140-
AtEOXact_Snapshot(true);
2140+
AtEOXact_Snapshot(true, false);
21412141
AtCommit_ApplyLauncher();
21422142
pgstat_report_xact_timestamp(0);
21432143

@@ -2409,7 +2409,7 @@ PrepareTransaction(void)
24092409
AtEOXact_ComboCid();
24102410
AtEOXact_HashTables(true);
24112411
/* don't call AtEOXact_PgStat here; we fixed pgstat state above */
2412-
AtEOXact_Snapshot(true);
2412+
AtEOXact_Snapshot(true, true);
24132413
pgstat_report_xact_timestamp(0);
24142414

24152415
CurrentResourceOwner=NULL;
@@ -2640,7 +2640,7 @@ CleanupTransaction(void)
26402640
* do abort cleanup processing
26412641
*/
26422642
AtCleanup_Portals();/* now safe to release portal memory */
2643-
AtEOXact_Snapshot(false);/* and release the transaction's snapshots */
2643+
AtEOXact_Snapshot(false, false);/* and release the transaction's snapshots */
26442644

26452645
CurrentResourceOwner=NULL;/* and resource owner */
26462646
if (TopTransactionResourceOwner)

‎src/backend/utils/time/snapmgr.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ AtSubAbort_Snapshot(int level)
10511051
*Snapshot manager's cleanup function for end of transaction
10521052
*/
10531053
void
1054-
AtEOXact_Snapshot(boolisCommit)
1054+
AtEOXact_Snapshot(boolisCommit,boolisPrepare)
10551055
{
10561056
/*
10571057
* In transaction-snapshot mode we must release our privately-managed
@@ -1136,7 +1136,17 @@ AtEOXact_Snapshot(bool isCommit)
11361136

11371137
FirstSnapshotSet= false;
11381138

1139-
SnapshotResetXmin();
1139+
/*
1140+
* During normal commit and abort processing, we call
1141+
* ProcArrayEndTransaction() or ProcArrayClearTransaction() to
1142+
* reset the PgXact->xmin. That call happens prior to the call to
1143+
* AtEOXact_Snapshot(), so we need not touch xmin here at all,
1144+
* accept when we are preparing a transaction.
1145+
*/
1146+
if (isPrepare)
1147+
SnapshotResetXmin();
1148+
1149+
Assert(isPrepare||MyPgXact->xmin==0);
11401150
}
11411151

11421152

‎src/include/utils/snapmgr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ extern void UnregisterSnapshotFromOwner(Snapshot snapshot, ResourceOwner owner);
8585

8686
externvoidAtSubCommit_Snapshot(intlevel);
8787
externvoidAtSubAbort_Snapshot(intlevel);
88-
externvoidAtEOXact_Snapshot(boolisCommit);
88+
externvoidAtEOXact_Snapshot(boolisCommit,boolisPrepare);
8989

9090
externvoidImportSnapshot(constchar*idstr);
9191
externboolXactHasExportedSnapshots(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp