From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Dilip Kumar <dilipbalaut@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: pgsql: Improve performance of subsystems on top of SLRU
Date: Mon, 4 Mar 2024 18:36:55 +0100
Message-ID: <202403041736.k5mrz5ntswt5@alvherre.pgsql> (raw)
In-Reply-To: <202403041517.3a35jw53os65@alvherre.pgsql>
FWIW there's a stupid bug in 0002, which is fixed here. I'm writing a
simple test for it.
--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"Now I have my system running, not a byte was off the shelf;
It rarely breaks and when it does I fix the code myself.
It's stable, clean and elegant, and lightning fast as well,
And it doesn't cost a nickel, so Bill Gates can go to hell."
Attachments:
[text/x-diff] v3-0001-Rework-redundant-loop-in-subtrans.c.patch (2.0K, ../202403041736.k5mrz5ntswt5@alvherre.pgsql/2-v3-0001-Rework-redundant-loop-in-subtrans.c.patch)
download | inline diff:
From ecf613092a3cbc4c5112d30af7eea55b668decec Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Mon, 4 Mar 2024 11:49:01 +0100
Subject: [PATCH v3] Rework redundant loop in subtrans.c
---
src/backend/access/transam/subtrans.c | 29 +++++++--------------------
1 file changed, 7 insertions(+), 22 deletions(-)
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.cindex dc9566fb51..50bb1d8cfc 100644--- a/src/backend/access/transam/subtrans.c+++ b/src/backend/access/transam/subtrans.c@@ -311,7 +311,7 @@ StartupSUBTRANS(TransactionId oldestActiveXID)
FullTransactionId nextXid;
int64 startPage;
int64 endPage;
- LWLock *prevlock;+ LWLock *prevlock = NULL;
LWLock *lock;
/*
@@ -324,42 +324,27 @@ StartupSUBTRANS(TransactionId oldestActiveXID)
nextXid = TransamVariables->nextXid;
endPage = TransactionIdToPage(XidFromFullTransactionId(nextXid));
- prevlock = SimpleLruGetBankLock(SubTransCtl, startPage);- LWLockAcquire(prevlock, LW_EXCLUSIVE);- while (startPage != endPage)+ for (;;)
{
lock = SimpleLruGetBankLock(SubTransCtl, startPage);
-- /*- * Check if we need to acquire the lock on the new bank then release- * the lock on the old bank and acquire on the new bank.- */
if (prevlock != lock)
{
- LWLockRelease(prevlock);+ if (prevlock)+ LWLockRelease(prevlock);
LWLockAcquire(lock, LW_EXCLUSIVE);
prevlock = lock;
}
(void) ZeroSUBTRANSPage(startPage);
+ if (startPage == endPage)+ break;+
startPage++;
/* must account for wraparound */
if (startPage > TransactionIdToPage(MaxTransactionId))
startPage = 0;
}
- lock = SimpleLruGetBankLock(SubTransCtl, startPage);-- /*- * Check if we need to acquire the lock on the new bank then release the- * lock on the old bank and acquire on the new bank.- */- if (prevlock != lock)- {- LWLockRelease(prevlock);- LWLockAcquire(lock, LW_EXCLUSIVE);- }- (void) ZeroSUBTRANSPage(startPage);
LWLockRelease(lock);
}
--
2.39.2
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@alvh.no-ip.org, tgl@sss.pgh.pa.us, dilipbalaut@gmail.com, pgsql-hackers@lists.postgresql.org
Subject: Re: pgsql: Improve performance of subsystems on top of SLRU
In-Reply-To: <202403041736.k5mrz5ntswt5@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox