mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-03 10:17:20 +02:00
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.
This commit is contained in:
parent
e14ed8e2f5
commit
fc0acf4387
@ -90,12 +90,18 @@ int sync_method = DEFAULT_SYNC_METHOD;
|
|||||||
int wal_level = WAL_LEVEL_MINIMAL;
|
int wal_level = WAL_LEVEL_MINIMAL;
|
||||||
int CommitDelay = 0; /* precommit delay in microseconds */
|
int CommitDelay = 0; /* precommit delay in microseconds */
|
||||||
int CommitSiblings = 5; /* # concurrent xacts needed to sleep */
|
int CommitSiblings = 5; /* # concurrent xacts needed to sleep */
|
||||||
int num_xloginsert_locks = 8;
|
|
||||||
|
|
||||||
#ifdef WAL_DEBUG
|
#ifdef WAL_DEBUG
|
||||||
bool XLOG_DEBUG = false;
|
bool XLOG_DEBUG = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Number of WAL insertion locks to use. A higher value allows more insertions
|
||||||
|
* to happen concurrently, but adds some CPU overhead to flushing the WAL,
|
||||||
|
* which needs to iterate all the locks.
|
||||||
|
*/
|
||||||
|
#define NUM_XLOGINSERT_LOCKS 8
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XLOGfileslop is the maximum number of preallocated future XLOG segments.
|
* XLOGfileslop is the maximum number of preallocated future XLOG segments.
|
||||||
* When we are done with an old XLOG segment file, we will recycle it as a
|
* When we are done with an old XLOG segment file, we will recycle it as a
|
||||||
@ -1089,9 +1095,9 @@ begin:;
|
|||||||
* inserter acquires an insertion lock. In addition to just indicating that
|
* inserter acquires an insertion lock. In addition to just indicating that
|
||||||
* an insertion is in progress, the lock tells others how far the inserter
|
* an insertion is in progress, the lock tells others how far the inserter
|
||||||
* has progressed. There is a small fixed number of insertion locks,
|
* has progressed. There is a small fixed number of insertion locks,
|
||||||
* determined by the num_xloginsert_locks GUC. When an inserter crosses a
|
* determined by NUM_XLOGINSERT_LOCKS. When an inserter crosses a page
|
||||||
* page boundary, it updates the value stored in the lock to the how far it
|
* boundary, it updates the value stored in the lock to the how far it has
|
||||||
* has inserted, to allow the previous buffer to be flushed.
|
* inserted, to allow the previous buffer to be flushed.
|
||||||
*
|
*
|
||||||
* Holding onto an insertion lock also protects RedoRecPtr and
|
* Holding onto an insertion lock also protects RedoRecPtr and
|
||||||
* fullPageWrites from changing until the insertion is finished.
|
* fullPageWrites from changing until the insertion is finished.
|
||||||
@ -1572,7 +1578,7 @@ WALInsertLockAcquire(void)
|
|||||||
static int lockToTry = -1;
|
static int lockToTry = -1;
|
||||||
|
|
||||||
if (lockToTry == -1)
|
if (lockToTry == -1)
|
||||||
lockToTry = MyProc->pgprocno % num_xloginsert_locks;
|
lockToTry = MyProc->pgprocno % NUM_XLOGINSERT_LOCKS;
|
||||||
MyLockNo = lockToTry;
|
MyLockNo = lockToTry;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1592,7 +1598,7 @@ WALInsertLockAcquire(void)
|
|||||||
* than locks, it still helps to distribute the inserters evenly
|
* than locks, it still helps to distribute the inserters evenly
|
||||||
* across the locks.
|
* across the locks.
|
||||||
*/
|
*/
|
||||||
lockToTry = (lockToTry + 1) % num_xloginsert_locks;
|
lockToTry = (lockToTry + 1) % NUM_XLOGINSERT_LOCKS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1611,7 +1617,7 @@ WALInsertLockAcquireExclusive(void)
|
|||||||
* than any real XLogRecPtr value, to make sure that no-one blocks waiting
|
* than any real XLogRecPtr value, to make sure that no-one blocks waiting
|
||||||
* on those.
|
* on those.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < num_xloginsert_locks - 1; i++)
|
for (i = 0; i < NUM_XLOGINSERT_LOCKS - 1; i++)
|
||||||
{
|
{
|
||||||
LWLockAcquireWithVar(&WALInsertLocks[i].l.lock,
|
LWLockAcquireWithVar(&WALInsertLocks[i].l.lock,
|
||||||
&WALInsertLocks[i].l.insertingAt,
|
&WALInsertLocks[i].l.insertingAt,
|
||||||
@ -1634,7 +1640,7 @@ WALInsertLockRelease(void)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < num_xloginsert_locks; i++)
|
for (i = 0; i < NUM_XLOGINSERT_LOCKS; i++)
|
||||||
LWLockRelease(&WALInsertLocks[i].l.lock);
|
LWLockRelease(&WALInsertLocks[i].l.lock);
|
||||||
|
|
||||||
holdingAllLocks = false;
|
holdingAllLocks = false;
|
||||||
@ -1658,8 +1664,8 @@ WALInsertLockUpdateInsertingAt(XLogRecPtr insertingAt)
|
|||||||
* We use the last lock to mark our actual position, see comments in
|
* We use the last lock to mark our actual position, see comments in
|
||||||
* WALInsertLockAcquireExclusive.
|
* WALInsertLockAcquireExclusive.
|
||||||
*/
|
*/
|
||||||
LWLockUpdateVar(&WALInsertLocks[num_xloginsert_locks - 1].l.lock,
|
LWLockUpdateVar(&WALInsertLocks[NUM_XLOGINSERT_LOCKS - 1].l.lock,
|
||||||
&WALInsertLocks[num_xloginsert_locks - 1].l.insertingAt,
|
&WALInsertLocks[NUM_XLOGINSERT_LOCKS - 1].l.insertingAt,
|
||||||
insertingAt);
|
insertingAt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1726,7 +1732,7 @@ WaitXLogInsertionsToFinish(XLogRecPtr upto)
|
|||||||
* out for any insertion that's still in progress.
|
* out for any insertion that's still in progress.
|
||||||
*/
|
*/
|
||||||
finishedUpto = reservedUpto;
|
finishedUpto = reservedUpto;
|
||||||
for (i = 0; i < num_xloginsert_locks; i++)
|
for (i = 0; i < NUM_XLOGINSERT_LOCKS; i++)
|
||||||
{
|
{
|
||||||
XLogRecPtr insertingat = InvalidXLogRecPtr;
|
XLogRecPtr insertingat = InvalidXLogRecPtr;
|
||||||
|
|
||||||
@ -4781,7 +4787,7 @@ XLOGShmemSize(void)
|
|||||||
size = sizeof(XLogCtlData);
|
size = sizeof(XLogCtlData);
|
||||||
|
|
||||||
/* WAL insertion locks, plus alignment */
|
/* WAL insertion locks, plus alignment */
|
||||||
size = add_size(size, mul_size(sizeof(WALInsertLockPadded), num_xloginsert_locks + 1));
|
size = add_size(size, mul_size(sizeof(WALInsertLockPadded), NUM_XLOGINSERT_LOCKS + 1));
|
||||||
/* xlblocks array */
|
/* xlblocks array */
|
||||||
size = add_size(size, mul_size(sizeof(XLogRecPtr), XLOGbuffers));
|
size = add_size(size, mul_size(sizeof(XLogRecPtr), XLOGbuffers));
|
||||||
/* extra alignment padding for XLOG I/O buffers */
|
/* extra alignment padding for XLOG I/O buffers */
|
||||||
@ -4840,7 +4846,7 @@ XLOGShmemInit(void)
|
|||||||
((uintptr_t) allocptr) %sizeof(WALInsertLockPadded);
|
((uintptr_t) allocptr) %sizeof(WALInsertLockPadded);
|
||||||
WALInsertLocks = XLogCtl->Insert.WALInsertLocks =
|
WALInsertLocks = XLogCtl->Insert.WALInsertLocks =
|
||||||
(WALInsertLockPadded *) allocptr;
|
(WALInsertLockPadded *) allocptr;
|
||||||
allocptr += sizeof(WALInsertLockPadded) * num_xloginsert_locks;
|
allocptr += sizeof(WALInsertLockPadded) * NUM_XLOGINSERT_LOCKS;
|
||||||
|
|
||||||
XLogCtl->Insert.WALInsertLockTrancheId = LWLockNewTrancheId();
|
XLogCtl->Insert.WALInsertLockTrancheId = LWLockNewTrancheId();
|
||||||
|
|
||||||
@ -4849,7 +4855,7 @@ XLOGShmemInit(void)
|
|||||||
XLogCtl->Insert.WALInsertLockTranche.array_stride = sizeof(WALInsertLockPadded);
|
XLogCtl->Insert.WALInsertLockTranche.array_stride = sizeof(WALInsertLockPadded);
|
||||||
|
|
||||||
LWLockRegisterTranche(XLogCtl->Insert.WALInsertLockTrancheId, &XLogCtl->Insert.WALInsertLockTranche);
|
LWLockRegisterTranche(XLogCtl->Insert.WALInsertLockTrancheId, &XLogCtl->Insert.WALInsertLockTranche);
|
||||||
for (i = 0; i < num_xloginsert_locks; i++)
|
for (i = 0; i < NUM_XLOGINSERT_LOCKS; i++)
|
||||||
{
|
{
|
||||||
LWLockInitialize(&WALInsertLocks[i].l.lock,
|
LWLockInitialize(&WALInsertLocks[i].l.lock,
|
||||||
XLogCtl->Insert.WALInsertLockTrancheId);
|
XLogCtl->Insert.WALInsertLockTrancheId);
|
||||||
|
@ -2119,17 +2119,6 @@ static struct config_int ConfigureNamesInt[] =
|
|||||||
NULL, NULL, NULL
|
NULL, NULL, NULL
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
|
||||||
{"xloginsert_locks", PGC_POSTMASTER, WAL_SETTINGS,
|
|
||||||
gettext_noop("Sets the number of locks used for concurrent xlog insertions."),
|
|
||||||
NULL,
|
|
||||||
GUC_NOT_IN_SAMPLE
|
|
||||||
},
|
|
||||||
&num_xloginsert_locks,
|
|
||||||
8, 1, 1000,
|
|
||||||
NULL, NULL, NULL
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
{
|
||||||
/* see max_connections */
|
/* see max_connections */
|
||||||
{"max_wal_senders", PGC_POSTMASTER, REPLICATION_SENDING,
|
{"max_wal_senders", PGC_POSTMASTER, REPLICATION_SENDING,
|
||||||
|
@ -192,7 +192,6 @@ extern bool EnableHotStandby;
|
|||||||
extern bool fullPageWrites;
|
extern bool fullPageWrites;
|
||||||
extern bool wal_log_hints;
|
extern bool wal_log_hints;
|
||||||
extern bool log_checkpoints;
|
extern bool log_checkpoints;
|
||||||
extern int num_xloginsert_locks;
|
|
||||||
|
|
||||||
/* WAL levels */
|
/* WAL levels */
|
||||||
typedef enum WalLevel
|
typedef enum WalLevel
|
||||||
|
Loading…
Reference in New Issue
Block a user