diff options
author | David Rowley <drowley@postgresql.org> | 2025-04-27 11:53:40 +1200 |
---|---|---|
committer | David Rowley <drowley@postgresql.org> | 2025-04-27 11:53:40 +1200 |
commit | 936457419d797dfaf37191db53d5efb1279eae6d (patch) | |
tree | ce4ab746e8e814bd18bad3bd561391a4ff0d5382 /contrib/jsonb_plpython/jsonb_plpython.c | |
parent | 27757677ca4da566ff21f65c58a008818afb5b06 (diff) | |
download | postgresql-936457419d797dfaf37191db53d5efb1279eae6d.tar.gz postgresql-936457419d797dfaf37191db53d5efb1279eae6d.zip |
Eliminate divide in new fast-path locking code
c4d5cb71d2 adjusted the fast-path locking code to allow some
configuration of the number of fast-path locking slots via the
max_locks_per_transaction GUC. In that commit the FAST_PATH_REL_GROUP()
macro used integer division to determine the fast-path locking group slot
to use for the lock.
The divisor in this case is always a power-of-two value. Here we swap
out the divide by a bitwise-AND, which is a significantly faster
operation to perform.
In passing, adjust the code that's setting FastPathLockGroupsPerBackend
so that it's more clear that the value being set is a power-of-two.
Also, adjust some comments in the area which contained some magic
numbers. It seems better to justify the 1024 upper limit in the
location where the #define is made instead of where it is used.
Author: David Rowley <drowleyml@gmail.com>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/CAApHDvodr3bcnpxcs7+k-3cFwYR0tP-BYhyd2PpDhe-bCx9i=g@mail.gmail.com
Diffstat (limited to 'contrib/jsonb_plpython/jsonb_plpython.c')
0 files changed, 0 insertions, 0 deletions