On Wed, Jul 09, 2025 at 04:39:48PM -0500, Sami Imseih wrote: > Attached is a proof of concept that does not alter the > LWLockRegisterTranche API.
IMHO we should consider modifying the API, because right now you have to call LWLockRegisterTranche() in each backend. Why not accept the name as an argument for LWLockNewTrancheId() and only require it to be called once during your shared memory initialization? In any case, a lot of existing code will continue to call it in each backend unless the API changes. > Instead, it detects when a registration is > performed by a normal backend and stores the tranche name in shared memory, > using a dshash keyed by tranche ID. Tranche name lookup now proceeds in > the order of built-in names, the local list, and finally the shared memory. > The fallback name "extension" can still be returned if an extension does > not register a tranche. Why do we need three different places for the lock names? Is there a reason we can't put it all in shared memory? > 1/ There is currently no mechanism for deleting entries. I am not sure whether > this is a concern, since the size of the table would grow only with the > number of extensions and the number of LWLocks they initialize, which is > typically small. That said, others may have different thoughts on this. I don't see any strong reason to allow deletion unless we started to reclaim tranche IDs, and I don't see any strong reason for that, either. > 2/ What is the appropriate size limit for a tranche name. The work done > in [0] caps the tranche name to 128 bytes for the dshash tranche, and > 128 bytes + length of " DSA" suffix for the dsa tranche. Also, the > existing RequestNamedLWLockTranche caps the name to NAMEDATALEN. Currently, > LWLockRegisterTranche does not have a limit on the tranche name. I wonder > if we also need to take care of this and implement some common limit that > applies to tranch names regardless of how they're created? Do we need to set a limit? If we're using a DSA and dshash, we could let folks use arbitrary long tranche names, right? The reason for the limit in the DSM registry is because the name is used as the key for the dshash table. -- nathan