From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
---|---|
To: | Sami Imseih <samimseih(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)anarazel(dot)de>, Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Rahila Syed <rahilasyed90(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Improve LWLock tranche name visibility across backends |
Date: | 2025-08-26 20:14:39 |
Message-ID: | aK4Vr0puSQqPI5vS@nathan |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Aug 26, 2025 at 02:56:22PM -0500, Sami Imseih wrote:
> Here is v12 that replaces the LWLock to access the shared memory with a
> ShmemLock and implements a local counter.
This looks much closer to what I was imagining.
/* Initialize the LWLock tranche for the DSA. */
- dsa_state->tranche = LWLockNewTrancheId();
+ dsa_state->tranche = LWLockNewTrancheId(dsa_state->tranche_name);
sprintf(dsa_state->tranche_name, "%s%s", name, DSMR_DSA_TRANCHE_SUFFIX);
- LWLockRegisterTranche(dsa_state->tranche, dsa_state->tranche_name);
/* Initialize the LWLock tranche for the dshash table. */
- dsh_state->tranche = LWLockNewTrancheId();
+ dsh_state->tranche = LWLockNewTrancheId(dsh_state->tranche_name);
strcpy(dsh_state->tranche_name, name);
- LWLockRegisterTranche(dsh_state->tranche, dsh_state->tranche_name);
We probably need to do the sprintf/strcpy before LWLockNewTrancheId().
Also, I'm thinking we should just use the same tranche for both the DSA and
the dshash table [0] to evade the DSMR_DSA_TRANCHE_SUFFIX problem, i.e.,
those tranche names potentially require more space.
+ /* Space for name of each tranche. */
+ size = add_size(size, mul_size(MAX_NAMED_TRANCHES, MAX_NAMED_TRANCHES));
Presumably one of the mul_size() arguments should be
MAX_NAMED_TRANCHES_NAME_LEN.
+NamedLWLockTrancheArray "Waiting to access the named LWLock tranches array."
+PG_LWLOCK(54, NamedLWLockTrancheArray)
These can be removed now, right?
[0] https://postgr.es/m/aKzIg1JryN1qhNuy%40nathan
--
nathan
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2025-08-26 20:16:34 | Re: plan shape work |
Previous Message | Jacob Champion | 2025-08-26 20:10:43 | Re: pgsql: oauth: Add unit tests for multiplexer handling |