From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Micro optimize LWLockAttemptLock() a bit. |
Date: | 2015-08-02 16:51:18 |
Message-ID: | E1ZLwTm-0005Nv-GR@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Micro optimize LWLockAttemptLock() a bit.
LWLockAttemptLock pointlessly read the lock's state in every loop
iteration, even though pg_atomic_compare_exchange_u32() returns the old
value. Instead do that only once before the loop iteration.
Additionally there's no need to have the expected_state variable,
old_state mostly had the same value anyway.
Noticed-By: Heikki Linnakangas
Backpatch: 9.5, no reason to let the branches diverge at this point
Branch
------
REL9_5_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/9074e41dbd41bc45ef79aeac1b6496bf087509a7
Modified Files
--------------
src/backend/storage/lmgr/lwlock.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2015-08-02 17:11:53 | pgsql: Fix race condition that lead to WALInsertLock deadlock with comm |
Previous Message | Andres Freund | 2015-08-02 16:51:15 | pgsql: Fix issues around the "variable" support in the lwlock infrastru |