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.fu...@gmail.com> Reviewed-by: Heikki Linnakangas <hlinn...@iki.fi> Reviewed-by: Ashutosh Bapat <ashutosh.bapat....@gmail.com> Discussion: https://postgr.es/m/07d5fd6a-71f1-4ce8-8602-4cc6883f4...@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(-)