pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Micro optimize LWLockAttemptLock() a bit.
2+ messages / 1 participants
[nested] [flat]

* pgsql: Micro optimize LWLockAttemptLock() a bit.
@ 2015-08-02 16:51  Andres Freund <andres@anarazel.de>
  0 siblings, 0 replies; 2+ messages in thread

From: Andres Freund @ 2015-08-02 16:51 UTC (permalink / raw)
  To: 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
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/a4b09af3e93707351f1d4b8efafabfa135c0f70b

Modified Files
--------------
src/backend/storage/lmgr/lwlock.c |   20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Micro optimize LWLockAttemptLock() a bit.
@ 2015-08-02 16:51  Andres Freund <andres@anarazel.de>
  0 siblings, 0 replies; 2+ messages in thread

From: Andres Freund @ 2015-08-02 16:51 UTC (permalink / raw)
  To: 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(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2015-08-02 16:51 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-08-02 16:51 pgsql: Micro optimize LWLockAttemptLock() a bit. Andres Freund <andres@anarazel.de>
2015-08-02 16:51 pgsql: Micro optimize LWLockAttemptLock() a bit. Andres Freund <andres@anarazel.de>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox