From 75e82b2f5a6f5de6b42dbd9ea73be5ff36a931b1 Mon Sep 17 00:00:00 2001 From: Alexander Korotkov Date: Tue, 18 Nov 2025 09:50:12 +0200 Subject: Optimize shared memory usage for WaitLSNProcInfo We need separate pairing heaps for different WaitLSNType's, because there might be waiters for different LSN's at the same time. However, one process can wait only for one type of LSN at a time. So, no need for inHeap and heapNode fields to be arrays. Discussion: https://postgr.es/m/CAPpHfdsBR-7sDtXFJ1qpJtKiohfGoj%3DvqzKVjWxtWsWidx7G_A%40mail.gmail.com Author: Alexander Korotkov Reviewed-by: Xuneng Zhou --- src/include/access/xlogwait.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/include/access/xlogwait.h') diff --git a/src/include/access/xlogwait.h b/src/include/access/xlogwait.h index f43e481c3b9..e607441d618 100644 --- a/src/include/access/xlogwait.h +++ b/src/include/access/xlogwait.h @@ -50,14 +50,20 @@ typedef struct WaitLSNProcInfo /* LSN, which this process is waiting for */ XLogRecPtr waitLSN; + /* The type of LSN to wait */ + WaitLSNType lsnType; + /* Process to wake up once the waitLSN is reached */ ProcNumber procno; - /* Heap membership flags for LSN types */ - bool inHeap[WAIT_LSN_TYPE_COUNT]; + /* + * Heap membership flag. A process can wait for only one LSN type at a + * time, so a single flag suffices (tracked by the lsnType field). + */ + bool inHeap; - /* Heap nodes for LSN types */ - pairingheap_node heapNode[WAIT_LSN_TYPE_COUNT]; + /* Pairing heap node for the waiters' heap (one per process) */ + pairingheap_node heapNode; } WaitLSNProcInfo; /* -- cgit v1.2.3