Re: MAX_BACKENDS size (comment accuracy)
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Jacob Brazeal <jacob.brazeal@gmail.com>
Cc: pgsql-hackers@postgresql.org
Date: 2025-01-26T18:15:11Z
Lists: pgsql-hackers
Hi,
On 2025-01-25 23:35:51 -0800, Jacob Brazeal wrote:
> While we are on the topic of comments from lwlock.c, there is one other one
> that confused me, in LWLockWaitListLock:
> * /* and then spin without atomic operations until lock is released */ {
> SpinDelayStatus delayStatus; init_local_spin_delay(&delayStatus); while
> (old_state & LW_FLAG_LOCKED) { perform_spin_delay(&delayStatus); old_state
> = pg_atomic_read_u32(&lock->state); }#ifdef LWLOCK_STATS delays +=
> delayStatus.delays;#endif finish_spin_delay(&delayStatus); }*
>
> It seems that we *are* using an atomic operation in the loop (though, no
> compare-and-set, etc.) I might be mis-reading the intent of the comment,
> but I'm curious if there's a way to reword it, too.
It's not really an atomic operation. It's just reading an atomic variable
(which just guarantees that the compiler isn't eliding the read and that the
read isn't torn). Personally I don't think there's a need to rephrase the
comment, but I probably wrote it, so take that with a grain of salt.
Greetings,
Andres Freund
PS: FYI, this list values properly quoting messages instead of replying ontop
of the entire quoted messages.
Commits
-
Fix comment for MAX_BACKENDS.
- c56e8af75e08 18.0 landed
-
Add static asserts for MAX_BACKENDS limiting factors
- 5ee75e32fa73 18.0 landed
-
Base LWLock limits directly on MAX_BACKENDS
- cd3ccf88aacb 18.0 landed
-
Move MAX_BACKENDS to procnumber.h
- 6394a3a61c0d 18.0 landed
-
bufmgr: Make it easier to change number of buffer state bits
- 418451bfe161 18.0 landed
-
Remove check hooks for GUCs that contribute to MaxBackends.
- 0b1fe1413ea8 18.0 cited
-
Allow Pin/UnpinBuffer to operate in a lockfree manner.
- 48354581a49c 9.6.0 cited