pgsql: Optimize iteration over PGPROC for fast-path lock searches. - Mailing list pgsql-committers

From Fujii Masao
Subject pgsql: Optimize iteration over PGPROC for fast-path lock searches.
Date
Msg-id E1tt5Rd-002Rk0-2X@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Optimize iteration over PGPROC for fast-path lock searches.

This commit improves efficiency in FastPathTransferRelationLocks()
and GetLockConflicts(), which iterate over PGPROCs to search for
fast-path locks.

Previously, these functions recalculated the fast-path group during
every loop iteration, even though it remained constant. This update
optimizes the process by calculating the group once and reusing it
throughout the loop.

The functions also now skip empty fast-path groups, avoiding
unnecessary scans of their slots. Additionally, groups belonging to
inactive backends (with pid=0) are always empty, so checking
the group is sufficient to bypass these backends, further enhancing
performance.

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Discussion: https://postgr.es/m/07d5fd6a-71f1-4ce8-8602-4cc6883f4bd1@oss.nttdata.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e80171d57c25caf4362a7de17e96195f905386ea

Modified Files
--------------
src/backend/storage/lmgr/lock.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: Simplify and generalize PrepareSortSupportFromIndexRel()
Next
From: Fujii Masao
Date:
Subject: pgsql: Add GUC option to log lock acquisition failures.