Skip to content

Commit fc0acf4

Browse files
committed
Remove num_xloginsert_locks GUC, replace with a #define
I left the GUC in place for the beta period, so that people could experiment with different values. No-one's come up with any data that a different value would be better under some circumstances, so rather than try to document to users what the GUC, let's just hard-code the current value, 8.
1 parent e14ed8e commit fc0acf4

File tree

3 files changed

+20
-26
lines changed

3 files changed

+20
-26
lines changed

src/backend/access/transam/xlog.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,18 @@ int sync_method = DEFAULT_SYNC_METHOD;
9090
int wal_level = WAL_LEVEL_MINIMAL;
9191
int CommitDelay = 0; /* precommit delay in microseconds */
9292
int CommitSiblings = 5; /* # concurrent xacts needed to sleep */
93-
int num_xloginsert_locks = 8;
9493

9594
#ifdef WAL_DEBUG
9695
bool XLOG_DEBUG = false;
9796
#endif
9897

98+
/*
99+
* Number of WAL insertion locks to use. A higher value allows more insertions
100+
* to happen concurrently, but adds some CPU overhead to flushing the WAL,
101+
* which needs to iterate all the locks.
102+
*/
103+
#define NUM_XLOGINSERT_LOCKS 8
104+
99105
/*
100106
* XLOGfileslop is the maximum number of preallocated future XLOG segments.
101107
* When we are done with an old XLOG segment file, we will recycle it as a
@@ -1089,9 +1095,9 @@ begin:;
10891095
* inserter acquires an insertion lock. In addition to just indicating that
10901096
* an insertion is in progress, the lock tells others how far the inserter
10911097
* has progressed. There is a small fixed number of insertion locks,
1092-
* determined by the num_xloginsert_locks GUC. When an inserter crosses a
1093-
* page boundary, it updates the value stored in the lock to the how far it
1094-
* has inserted, to allow the previous buffer to be flushed.
1098+
* determined by NUM_XLOGINSERT_LOCKS. When an inserter crosses a page
1099+
* boundary, it updates the value stored in the lock to the how far it has
1100+
* inserted, to allow the previous buffer to be flushed.
10951101
*
10961102
* Holding onto an insertion lock also protects RedoRecPtr and
10971103
* fullPageWrites from changing until the insertion is finished.
@@ -1572,7 +1578,7 @@ WALInsertLockAcquire(void)
15721578
static int lockToTry = -1;
15731579

15741580
if (lockToTry == -1)
1575-
lockToTry = MyProc->pgprocno % num_xloginsert_locks;
1581+
lockToTry = MyProc->pgprocno % NUM_XLOGINSERT_LOCKS;
15761582
MyLockNo = lockToTry;
15771583

15781584
/*
@@ -1592,7 +1598,7 @@ WALInsertLockAcquire(void)
15921598
* than locks, it still helps to distribute the inserters evenly
15931599
* across the locks.
15941600
*/
1595-
lockToTry = (lockToTry + 1) % num_xloginsert_locks;
1601+
lockToTry = (lockToTry + 1) % NUM_XLOGINSERT_LOCKS;
15961602
}
15971603
}
15981604

@@ -1611,7 +1617,7 @@ WALInsertLockAcquireExclusive(void)
16111617
* than any real XLogRecPtr value, to make sure that no-one blocks waiting
16121618
* on those.
16131619
*/
1614-
for (i = 0; i < num_xloginsert_locks - 1; i++)
1620+
for (i = 0; i < NUM_XLOGINSERT_LOCKS - 1; i++)
16151621
{
16161622
LWLockAcquireWithVar(&WALInsertLocks[i].l.lock,
16171623
&WALInsertLocks[i].l.insertingAt,
@@ -1634,7 +1640,7 @@ WALInsertLockRelease(void)
16341640
{
16351641
int i;
16361642

1637-
for (i = 0; i < num_xloginsert_locks; i++)
1643+
for (i = 0; i < NUM_XLOGINSERT_LOCKS; i++)
16381644
LWLockRelease(&WALInsertLocks[i].l.lock);
16391645

16401646
holdingAllLocks = false;
@@ -1658,8 +1664,8 @@ WALInsertLockUpdateInsertingAt(XLogRecPtr insertingAt)
16581664
* We use the last lock to mark our actual position, see comments in
16591665
* WALInsertLockAcquireExclusive.
16601666
*/
1661-
LWLockUpdateVar(&WALInsertLocks[num_xloginsert_locks - 1].l.lock,
1662-
&WALInsertLocks[num_xloginsert_locks - 1].l.insertingAt,
1667+
LWLockUpdateVar(&WALInsertLocks[NUM_XLOGINSERT_LOCKS - 1].l.lock,
1668+
&WALInsertLocks[NUM_XLOGINSERT_LOCKS - 1].l.insertingAt,
16631669
insertingAt);
16641670
}
16651671
else
@@ -1726,7 +1732,7 @@ WaitXLogInsertionsToFinish(XLogRecPtr upto)
17261732
* out for any insertion that's still in progress.
17271733
*/
17281734
finishedUpto = reservedUpto;
1729-
for (i = 0; i < num_xloginsert_locks; i++)
1735+
for (i = 0; i < NUM_XLOGINSERT_LOCKS; i++)
17301736
{
17311737
XLogRecPtr insertingat = InvalidXLogRecPtr;
17321738

@@ -4781,7 +4787,7 @@ XLOGShmemSize(void)
47814787
size = sizeof(XLogCtlData);
47824788

47834789
/* WAL insertion locks, plus alignment */
4784-
size = add_size(size, mul_size(sizeof(WALInsertLockPadded), num_xloginsert_locks + 1));
4790+
size = add_size(size, mul_size(sizeof(WALInsertLockPadded), NUM_XLOGINSERT_LOCKS + 1));
47854791
/* xlblocks array */
47864792
size = add_size(size, mul_size(sizeof(XLogRecPtr), XLOGbuffers));
47874793
/* extra alignment padding for XLOG I/O buffers */
@@ -4840,7 +4846,7 @@ XLOGShmemInit(void)
48404846
((uintptr_t) allocptr) %sizeof(WALInsertLockPadded);
48414847
WALInsertLocks = XLogCtl->Insert.WALInsertLocks =
48424848
(WALInsertLockPadded *) allocptr;
4843-
allocptr += sizeof(WALInsertLockPadded) * num_xloginsert_locks;
4849+
allocptr += sizeof(WALInsertLockPadded) * NUM_XLOGINSERT_LOCKS;
48444850

48454851
XLogCtl->Insert.WALInsertLockTrancheId = LWLockNewTrancheId();
48464852

@@ -4849,7 +4855,7 @@ XLOGShmemInit(void)
48494855
XLogCtl->Insert.WALInsertLockTranche.array_stride = sizeof(WALInsertLockPadded);
48504856

48514857
LWLockRegisterTranche(XLogCtl->Insert.WALInsertLockTrancheId, &XLogCtl->Insert.WALInsertLockTranche);
4852-
for (i = 0; i < num_xloginsert_locks; i++)
4858+
for (i = 0; i < NUM_XLOGINSERT_LOCKS; i++)
48534859
{
48544860
LWLockInitialize(&WALInsertLocks[i].l.lock,
48554861
XLogCtl->Insert.WALInsertLockTrancheId);

src/backend/utils/misc/guc.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,17 +2119,6 @@ static struct config_int ConfigureNamesInt[] =
21192119
NULL, NULL, NULL
21202120
},
21212121

2122-
{
2123-
{"xloginsert_locks", PGC_POSTMASTER, WAL_SETTINGS,
2124-
gettext_noop("Sets the number of locks used for concurrent xlog insertions."),
2125-
NULL,
2126-
GUC_NOT_IN_SAMPLE
2127-
},
2128-
&num_xloginsert_locks,
2129-
8, 1, 1000,
2130-
NULL, NULL, NULL
2131-
},
2132-
21332122
{
21342123
/* see max_connections */
21352124
{"max_wal_senders", PGC_POSTMASTER, REPLICATION_SENDING,

src/include/access/xlog.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ extern bool EnableHotStandby;
192192
extern bool fullPageWrites;
193193
extern bool wal_log_hints;
194194
extern bool log_checkpoints;
195-
extern int num_xloginsert_locks;
196195

197196
/* WAL levels */
198197
typedef enum WalLevel

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