Skip to content
Snippets Groups Projects
Commit 0fad355b authored by Robert Haas's avatar Robert Haas
Browse files

Update obsolete comments in lwlock.h.

The typical size of an LWLock is now 16 bytes even on 64-bit platforms,
and the size of slock_t is now irrelevant.  But pg_atomic_uint32 can
(perhaps surprisingly) still be larger than 4 bytes, so there's still
some marginal point to allowing LWLOCK_MINIMAL_SIZE == 64.

Commit 008608b9 made the changes
that led to the need for these updates.
parent 0813216c
No related branches found
No related tags found
No related merge requests found
...@@ -58,16 +58,17 @@ typedef struct LWLock ...@@ -58,16 +58,17 @@ typedef struct LWLock
* LWLockPadded can be used for cases where we want each lock to be an entire * LWLockPadded can be used for cases where we want each lock to be an entire
* cache line. * cache line.
* *
* On 32-bit platforms, an LWLockMinimallyPadded might actually contain more * An LWLockMinimallyPadded might contain more than the absolute minimum amount
* than the absolute minimum amount of padding required to keep a lock from * of padding required to keep a lock from crossing a cache line boundary,
* crossing a cache line boundary, because an unpadded LWLock might fit into * because an unpadded LWLock will normally fit into 16 bytes. We ignore that
* 16 bytes. We ignore that possibility when determining the minimal amount * possibility when determining the minimal amount of padding. Older releases
* of padding. Older releases had larger LWLocks, so 32 really was the * had larger LWLocks, so 32 really was the minimum, and packing them in
* minimum, and packing them in tighter might hurt performance. * tighter might hurt performance.
* *
* LWLOCK_MINIMAL_SIZE should be 32 on basically all common platforms, but * LWLOCK_MINIMAL_SIZE should be 32 on basically all common platforms, but
* because slock_t is more than 2 bytes on some obscure platforms, we allow * because pg_atomic_uint32 is more than 4 bytes on some obscure platforms, we
* for the possibility that it might be 64. * allow for the possibility that it might be 64. Even on those platforms,
* we probably won't exceed 32 bytes unless LOCK_DEBUG is defined.
*/ */
#define LWLOCK_PADDED_SIZE PG_CACHE_LINE_SIZE #define LWLOCK_PADDED_SIZE PG_CACHE_LINE_SIZE
#define LWLOCK_MINIMAL_SIZE (sizeof(LWLock) <= 32 ? 32 : 64) #define LWLOCK_MINIMAL_SIZE (sizeof(LWLock) <= 32 ? 32 : 64)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment