mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
Revert "Add single-item cache when looking at topmost XID of a subtrans XID"
This reverts commit 06f5295 as per issues with this approach, both in terms of efficiency impact and stability. First, contrary to the single-item cache for transaction IDs in transam.c, the cache may finish by not be hit for a long time, and without an invalidation mechanism to clear it, it would cause inconsistent results on wraparound for example. Second, the use of SubTransGetTopmostTransaction() for the caching has a limited impact on performance. SubTransGetParent() could have more impact, though the benchmarking of the single-item approach still needs to be proved, particularly under the conditions where SLRU lookups are stressed in parallel with overflowed snapshots (aka more than 64 subxids generated, for example). After discussion with Andres Freund. Discussion: https://postgr.es/m/20220524235250.gtt3uu5zktfkr4hv@alap3.anarazel.de
This commit is contained in:
parent
f1431f3bff
commit
b4529005fd
@ -54,14 +54,6 @@
|
|||||||
#define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE)
|
#define TransactionIdToPage(xid) ((xid) / (TransactionId) SUBTRANS_XACTS_PER_PAGE)
|
||||||
#define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE)
|
#define TransactionIdToEntry(xid) ((xid) % (TransactionId) SUBTRANS_XACTS_PER_PAGE)
|
||||||
|
|
||||||
/*
|
|
||||||
* Single-item cache for results of SubTransGetTopmostTransaction(). It's
|
|
||||||
* worth having such a cache because we frequently find ourselves repeatedly
|
|
||||||
* checking the same XID, for example when scanning a table just after a
|
|
||||||
* bulk insert, update, or delete.
|
|
||||||
*/
|
|
||||||
static TransactionId cachedFetchSubXid = InvalidTransactionId;
|
|
||||||
static TransactionId cachedFetchTopmostXid = InvalidTransactionId;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Link to shared-memory data structures for SUBTRANS control
|
* Link to shared-memory data structures for SUBTRANS control
|
||||||
@ -163,13 +155,6 @@ SubTransGetTopmostTransaction(TransactionId xid)
|
|||||||
/* Can't ask about stuff that might not be around anymore */
|
/* Can't ask about stuff that might not be around anymore */
|
||||||
Assert(TransactionIdFollowsOrEquals(xid, TransactionXmin));
|
Assert(TransactionIdFollowsOrEquals(xid, TransactionXmin));
|
||||||
|
|
||||||
/*
|
|
||||||
* Before going to the subtrans log, check our single item cache to see if
|
|
||||||
* we know the result from a previous/recent request.
|
|
||||||
*/
|
|
||||||
if (TransactionIdEquals(xid, cachedFetchSubXid))
|
|
||||||
return cachedFetchTopmostXid;
|
|
||||||
|
|
||||||
while (TransactionIdIsValid(parentXid))
|
while (TransactionIdIsValid(parentXid))
|
||||||
{
|
{
|
||||||
previousXid = parentXid;
|
previousXid = parentXid;
|
||||||
@ -189,9 +174,6 @@ SubTransGetTopmostTransaction(TransactionId xid)
|
|||||||
|
|
||||||
Assert(TransactionIdIsValid(previousXid));
|
Assert(TransactionIdIsValid(previousXid));
|
||||||
|
|
||||||
cachedFetchSubXid = xid;
|
|
||||||
cachedFetchTopmostXid = previousXid;
|
|
||||||
|
|
||||||
return previousXid;
|
return previousXid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user