Optimizing FastPathTransferRelationLocks()
Fujii Masao <masao.fujii@oss.nttdata.com>
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: pgsql-hackers@lists.postgresql.org
Date: 2024-11-12T01:16:37Z
Lists: pgsql-hackers
Attachments
- v1-0001-Optimize-lock-transfer-from-per-backend-fast-path.patch (text/plain) patch v1-0001
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
Commits
-
Optimize iteration over PGPROC for fast-path lock searches.
- e80171d57c25 18.0 landed
-
Increase the number of fast-path lock slots
- c4d5cb71d229 18.0 cited