mirror of
https://github.com/postgres/postgres.git
synced 2025-08-31 17:02:12 +03:00
Convert the PGPROC->lwWaitLink list into a dlist instead of open coding it.
Besides being shorter and much easier to read it changes the logic in LWLockRelease() to release all shared lockers when waking up any. This can yield some significant performance improvements - and the fairness isn't really much worse than before, as we always allowed new shared lockers to jump the queue.
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#ifndef LWLOCK_H
|
||||
#define LWLOCK_H
|
||||
|
||||
#include "lib/ilist.h"
|
||||
#include "storage/s_lock.h"
|
||||
|
||||
struct PGPROC;
|
||||
@@ -50,9 +51,7 @@ typedef struct LWLock
|
||||
char exclusive; /* # of exclusive holders (0 or 1) */
|
||||
int shared; /* # of shared holders (0..MaxBackends) */
|
||||
int tranche; /* tranche ID */
|
||||
struct PGPROC *head; /* head of list of waiting PGPROCs */
|
||||
struct PGPROC *tail; /* tail of list of waiting PGPROCs */
|
||||
/* tail is undefined when head is NULL */
|
||||
dlist_head waiters; /* list of waiting PGPROCs */
|
||||
} LWLock;
|
||||
|
||||
/*
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#define _PROC_H_
|
||||
|
||||
#include "access/xlogdefs.h"
|
||||
#include "lib/ilist.h"
|
||||
#include "storage/latch.h"
|
||||
#include "storage/lock.h"
|
||||
#include "storage/pg_sema.h"
|
||||
@@ -104,7 +105,7 @@ struct PGPROC
|
||||
/* Info about LWLock the process is currently waiting for, if any. */
|
||||
bool lwWaiting; /* true if waiting for an LW lock */
|
||||
uint8 lwWaitMode; /* lwlock mode being waited for */
|
||||
struct PGPROC *lwWaitLink; /* next waiter for same LW lock */
|
||||
dlist_node lwWaitLink; /* position in LW lock wait list */
|
||||
|
||||
/* Info about lock the process is currently waiting for, if any. */
|
||||
/* waitLock and waitProcLock are NULL if not currently waiting. */
|
||||
|
Reference in New Issue
Block a user