Skip to content

Commit 2f39106

Browse files
committed
Replace CAS loop with single TAS in ProcArrayGroupClearXid()
Single pg_atomic_exchange_u32() is expected to be faster than loop of pg_atomic_compare_exchange_u32(). Also, it would be consistent with clog group update code. Discussion: https://postgr.es/m/CAPpHfdtxLsC-bqfxFcHswZ91OxXcZVNDBBVfg9tAWU0jvn1tQA%40mail.gmail.com Reviewed-by: Amit Kapila
1 parent db361db commit 2f39106

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/backend/storage/ipc/procarray.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -542,14 +542,8 @@ ProcArrayGroupClearXid(PGPROC *proc, TransactionId latestXid)
542542
* group XID clearing, saving a pointer to the head of the list. Trying
543543
* to pop elements one at a time could lead to an ABA problem.
544544
*/
545-
while (true)
546-
{
547-
nextidx = pg_atomic_read_u32(&procglobal->procArrayGroupFirst);
548-
if (pg_atomic_compare_exchange_u32(&procglobal->procArrayGroupFirst,
549-
&nextidx,
550-
INVALID_PGPROCNO))
551-
break;
552-
}
545+
nextidx = pg_atomic_exchange_u32(&procglobal->procArrayGroupFirst,
546+
INVALID_PGPROCNO);
553547

554548
/* Remember head of list so we can perform wakeups after dropping lock. */
555549
wakeidx = nextidx;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy