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

Commit11e178d

Browse files
committed
Inline initial comparisons in TestForOldSnapshot()
Even with old_snapshot_threshold = -1 (which disables the "snapshottoo old" feature), performance regressions were seen at moderate tohigh concurrency. For example, a one-socket, four-core systemrunning 200 connections at saturation could see up to a 2.3%regression, with larger regressions possible on NUMA machines.By inlining the early (smaller, faster) tests in theTestForOldSnapshot() function, the i7 case dropped to a 0.2%regression, which could easily just be noise, and is clearly animprovement. Further testing will show whether more is needed.
1 parent5b1f9ce commit11e178d

File tree

2 files changed

+36
-24
lines changed

2 files changed

+36
-24
lines changed

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4282,33 +4282,15 @@ IssuePendingWritebacks(WritebackContext *context)
42824282

42834283

42844284
/*
4285-
* Check whether the given snapshot is too old to have safely read the given
4286-
* page from the given table. If so, throw a "snapshot too old" error.
4285+
* Implement slower/larger portions of TestForOldSnapshot
42874286
*
4288-
* This test generally needs to be performed after every BufferGetPage() call
4289-
* that is executed as part of a scan. It is not needed for calls made for
4290-
* modifying the page (for example, to position to the right place to insert a
4291-
* new index tuple or for vacuuming). It may also be omitted where calls to
4292-
* lower-level functions will have already performed the test.
4293-
*
4294-
* Note that a NULL snapshot argument is allowed and causes a fast return
4295-
* without error; this is to support call sites which can be called from
4296-
* either scans or index modification areas.
4297-
*
4298-
* For best performance, keep the tests that are fastest and/or most likely to
4299-
* exclude a page from old snapshot testing near the front.
4287+
* Smaller/faster portions are put inline, but the entire set of logic is too
4288+
* big for that.
43004289
*/
43014290
void
4302-
TestForOldSnapshot(Snapshotsnapshot,Relationrelation,Pagepage)
4291+
TestForOldSnapshot_impl(Snapshotsnapshot,Relationrelation)
43034292
{
4304-
Assert(relation!=NULL);
4305-
4306-
if (old_snapshot_threshold >=0
4307-
&& (snapshot)!=NULL
4308-
&& (snapshot)->satisfies==HeapTupleSatisfiesMVCC
4309-
&& !XLogRecPtrIsInvalid((snapshot)->lsn)
4310-
&&PageGetLSN(page)> (snapshot)->lsn
4311-
&& !IsCatalogRelation(relation)
4293+
if (!IsCatalogRelation(relation)
43124294
&& !RelationIsAccessibleInLogicalDecoding(relation)
43134295
&& (snapshot)->whenTaken<GetOldSnapshotThresholdTimestamp())
43144296
ereport(ERROR,

‎src/include/storage/bufmgr.h

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ extern bool BgBufferSync(struct WritebackContext *wb_context);
239239

240240
externvoidAtProcExit_LocalBuffers(void);
241241

242-
externvoidTestForOldSnapshot(Snapshotsnapshot,Relationrelation,Pagepage);
242+
externvoidTestForOldSnapshot_impl(Snapshotsnapshot,Relationrelation);
243243

244244
/* in freelist.c */
245245
externBufferAccessStrategyGetAccessStrategy(BufferAccessStrategyTypebtype);
@@ -257,6 +257,36 @@ extern void FreeAccessStrategy(BufferAccessStrategy strategy);
257257

258258
#ifndefFRONTEND
259259

260+
/*
261+
* Check whether the given snapshot is too old to have safely read the given
262+
* page from the given table. If so, throw a "snapshot too old" error.
263+
*
264+
* This test generally needs to be performed after every BufferGetPage() call
265+
* that is executed as part of a scan. It is not needed for calls made for
266+
* modifying the page (for example, to position to the right place to insert a
267+
* new index tuple or for vacuuming). It may also be omitted where calls to
268+
* lower-level functions will have already performed the test.
269+
*
270+
* Note that a NULL snapshot argument is allowed and causes a fast return
271+
* without error; this is to support call sites which can be called from
272+
* either scans or index modification areas.
273+
*
274+
* For best performance, keep the tests that are fastest and/or most likely to
275+
* exclude a page from old snapshot testing near the front.
276+
*/
277+
staticinlinevoid
278+
TestForOldSnapshot(Snapshotsnapshot,Relationrelation,Pagepage)
279+
{
280+
Assert(relation!=NULL);
281+
282+
if (old_snapshot_threshold >=0
283+
&& (snapshot)!=NULL
284+
&& (snapshot)->satisfies==HeapTupleSatisfiesMVCC
285+
&& !XLogRecPtrIsInvalid((snapshot)->lsn)
286+
&&PageGetLSN(page)> (snapshot)->lsn)
287+
TestForOldSnapshot_impl(snapshot,relation);
288+
}
289+
260290
#endif/* FRONTEND */
261291

262292
#endif/* BUFMGR_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp