Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 29c3e2d

Browse files
committed
Collect built-in LWLock tranche names statically, not dynamically.
There is little point in using the LWLockRegisterTranche mechanism for built-in tranche names. It wastes cycles, it creates opportunities for bugs (since failing to register a tranche name is a very hard-to-detect problem), and the lack of any centralized list of names encourages sloppy nonconformity in name choices. Moreover, since we have a centralized list of the tranches anyway in enum BuiltinTrancheIds, we're certainly not buying any flexibility in return for these disadvantages. Hence, nuke all the backend-internal LWLockRegisterTranche calls, and instead provide a const array of the builtin tranche names. (I have in mind to change a bunch of these names shortly, but this patch is just about getting them into one place.) Discussion: https://postgr.es/m/9056.1589419765@sss.pgh.pa.us
1 parent 07451e1 commit 29c3e2d

File tree

7 files changed

+168
-110
lines changed

7 files changed

+168
-110
lines changed

src/backend/access/transam/slru.c

-3
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,6 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
235235
else
236236
Assert(found);
237237

238-
/* Register SLRU tranche in the main tranches array */
239-
LWLockRegisterTranche(tranche_id, name);
240-
241238
/*
242239
* Initialize the unshared control struct, including directory path. We
243240
* assume caller set PagePrecedes.

src/backend/access/transam/xlog.c

+1-4
Original file line numberDiff line numberDiff line change
@@ -5116,10 +5116,8 @@ XLOGShmemInit(void)
51165116
/* both should be present or neither */
51175117
Assert(foundCFile && foundXLog);
51185118

5119-
/* Initialize local copy of WALInsertLocks and register the tranche */
5119+
/* Initialize local copy of WALInsertLocks */
51205120
WALInsertLocks = XLogCtl->Insert.WALInsertLocks;
5121-
LWLockRegisterTranche(LWTRANCHE_WAL_INSERT,
5122-
"wal_insert");
51235121

51245122
if (localControlFile)
51255123
pfree(localControlFile);
@@ -5155,7 +5153,6 @@ XLOGShmemInit(void)
51555153
(WALInsertLockPadded *) allocptr;
51565154
allocptr += sizeof(WALInsertLockPadded) * NUM_XLOGINSERT_LOCKS;
51575155

5158-
LWLockRegisterTranche(LWTRANCHE_WAL_INSERT, "wal_insert");
51595156
for (i = 0; i < NUM_XLOGINSERT_LOCKS; i++)
51605157
{
51615158
LWLockInitialize(&WALInsertLocks[i].l.lock, LWTRANCHE_WAL_INSERT);

src/backend/replication/logical/origin.c

-3
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,6 @@ ReplicationOriginShmemInit(void)
517517
ConditionVariableInit(&replication_states[i].origin_cv);
518518
}
519519
}
520-
521-
LWLockRegisterTranche(replication_states_ctl->tranche_id,
522-
"replication_origin");
523520
}
524521

525522
/* ---------------------------------------------------------------------------

src/backend/replication/slot.c

-3
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ ReplicationSlotsShmemInit(void)
140140
ShmemInitStruct("ReplicationSlot Ctl", ReplicationSlotsShmemSize(),
141141
&found);
142142

143-
LWLockRegisterTranche(LWTRANCHE_REPLICATION_SLOT_IO_IN_PROGRESS,
144-
"replication_slot_io");
145-
146143
if (!found)
147144
{
148145
int i;

src/backend/storage/buffer/buf_init.c

-3
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ InitBufferPool(void)
8787
NBuffers * (Size) sizeof(LWLockMinimallyPadded),
8888
&foundIOLocks);
8989

90-
LWLockRegisterTranche(LWTRANCHE_BUFFER_IO_IN_PROGRESS, "buffer_io");
91-
LWLockRegisterTranche(LWTRANCHE_BUFFER_CONTENT, "buffer_content");
92-
9390
/*
9491
* The array used to sort to-be-checkpointed buffer ids is located in
9592
* shared memory, to avoid having to allocate significant amounts of

src/backend/storage/ipc/procarray.c

-2
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,6 @@ CreateSharedProcArray(void)
267267
mul_size(sizeof(bool), TOTAL_MAX_CACHED_SUBXIDS),
268268
&found);
269269
}
270-
271-
LWLockRegisterTranche(LWTRANCHE_PROC, "proc");
272270
}
273271

274272
/*

0 commit comments

Comments
 (0)