From: | Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> |
---|---|
To: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Optimizing FastPathTransferRelationLocks() |
Date: | 2024-11-19 16:43:53 |
Message-ID: | ebc772f6-238f-496f-8aeb-31be0c788713@oss.nttdata.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2024/11/16 7:15, Heikki Linnakangas wrote:
> On 12/11/2024 03:16, Fujii Masao wrote:
>> Hi,
>>
>> I've identified some opportunities to optimize FastPathTransferRelationLocks(), which transfers locks with a
>> specific lock tag from per-backend fast- path arrays to the shared
>> hash table. The attached patch includes these enhancements.
>>
>> Currently, FastPathTransferRelationLocks() recalculates the fast-
>> path group on each loop iteration, even though it stays the same.
>> This patch updates the function to calculate the group once and
>> reuse it, improving efficiency.
>
> Makes sense. GetLockConflicts() has similar code, the same optimizations would apply there too.
Yes, I've updated the patch as suggested.
>> The patch also extends the function's logic to skip not only
>> backends from a different database but also backends with pid=0
>> (which don’t hold fast-path locks) and groups with no registered
>> fast-path locks.
>>
>> Since MyProc->pid is reset to 0 when a backend exits but MyProc-
>> >databaseId remains set, checking only databaseId isn’t enough.
>> Backends with pid=0 also should be skipped.
> Hmm, a PGPROC entry that's not in use would also have proc->fpLockBits[group] == 0, so I'm not sure if the check for proc->pid == 0 is necessary.
You're right. I've removed the check for proc->pid == 0.
Also I added a check for proc->fpLockBits[group] == 0 in GetLockConflicts().
The latest version of the patch is attached.
> And perhaps we should start clearing databaseid on backend exit.
Maybe, but I'm not sure if we really need this..
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
Attachment | Content-Type | Size |
---|---|---|
v2-0001-Optimize-iteration-over-PGPROC-for-fast-path-lock.patch | text/plain | 4.1 KB |
From | Date | Subject | |
---|---|---|---|
Previous Message | Vik Fearing | 2024-11-19 16:38:36 | Re: SQL Property Graph Queries (SQL/PGQ) |