#include "postgres.h"
#include "miscadmin.h"
+#include "replication/walsender.h"
#include "storage/lwlock.h"
#include "storage/spin.h"
int
SpinlockSemas(void)
{
+ int nsemas;
+
/*
* It would be cleaner to distribute this logic into the affected modules,
* similar to the way shmem space estimation is handled.
*
- * For now, though, we just need a few spinlocks (10 should be plenty)
- * plus one for each LWLock and one for each buffer header.
+ * For now, though, there are few enough users of spinlocks that we just
+ * keep the knowledge here.
*/
- return NumLWLocks() + NBuffers + 10;
+ nsemas = NumLWLocks(); /* one for each lwlock */
+ nsemas += NBuffers; /* one for each buffer header */
+ nsemas += max_wal_senders; /* one for each wal sender process */
+ nsemas += 30; /* plus a bunch for other small-scale use */
+
+ return nsemas;
}
/*