From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tomas Vondra <tomas(at)vondra(dot)me> |
Subject: | Get rid of integer divide in FAST_PATH_REL_GROUP() macro |
Date: | 2025-04-14 02:09:16 |
Message-ID: | CAApHDvodr3bcnpxcs7+k-3cFwYR0tP-BYhyd2PpDhe-bCx9i=g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I noticed a while ago that the new fast-path locking code uses integer
division to figure out the fast-path locking group slot. To me, this
seems a bit unnecessary as FastPathLockGroupsPerBackend is always a
power-of-two value, so we can use bitwise-AND instead.
I don't think FAST_PATH_REL_GROUP() is in any particularly hot code
paths, but still, having the divide in there isn't sitting well with
me. Can we get rid of it?
I've attached a patch for that. I also adjusted the method used to
calculate FastPathLockGroupsPerBackend. Also, the Assert that was
going on at the end of the loop in InitializeFastPathLocks() looked a
little odd as it seems to be verifying something that the loop
condition was checking already. I thought it was better to check that
we end up with a power-of-two.
Please see the attached patch.
David
Attachment | Content-Type | Size |
---|---|---|
v1-0001-Eliminate-integer-divide-in-fastpath-locking-code.patch | application/octet-stream | 4.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Smith | 2025-04-14 02:56:01 | Re: Logical Replication of sequences |
Previous Message | Richard Guo | 2025-04-14 01:25:06 | Re: New committer: Jacob Champion |