Optimizing FastPathTransferRelationLocks()

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Optimizing FastPathTransferRelationLocks()
Date: 2024-11-12 01:16:37
Message-ID: 07d5fd6a-71f1-4ce8-8602-4cc6883f4bd1@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

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.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachment Content-Type Size
v1-0001-Optimize-lock-transfer-from-per-backend-fast-path.patch text/plain 2.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message torikoshia 2024-11-12 01:16:50 Re: Add reject_limit option to file_fdw
Previous Message Tom Lane 2024-11-12 01:13:44 Re: intarray sort returns wrong result