mirror of
https://github.com/postgres/postgres.git
synced 2025-08-24 09:27:52 +03:00
Reduce the number of semaphores used under --disable-spinlocks.
Instead of allocating a semaphore from the operating system for every spinlock, allocate a fixed number of semaphores (by default, 1024) from the operating system and multiplex all the spinlocks that get created onto them. This could self-deadlock if a process attempted to acquire more than one spinlock at a time, but since processes aren't supposed to execute anything other than short stretches of straight-line code while holding a spinlock, that shouldn't happen. One motivation for this change is that, with the introduction of dynamic shared memory, it may be desirable to create spinlocks that last for less than the lifetime of the server. Without this change, attempting to use such facilities under --disable-spinlocks would quickly exhaust any supply of available semaphores. Quite apart from that, it's desirable to contain the quantity of semaphores needed to run the server simply on convenience grounds, since using too many may make it harder to get PostgreSQL running on a new platform, which is mostly the point of --disable-spinlocks in the first place. Patch by me; review by Tom Lane.
This commit is contained in:
@@ -56,6 +56,14 @@
|
||||
*/
|
||||
#define NUM_USER_DEFINED_LWLOCKS 4
|
||||
|
||||
/*
|
||||
* When we don't have native spinlocks, we use semaphores to simulate them.
|
||||
* Decreasing this value reduces consumption of OS resources; increasing it
|
||||
* may improve performance, but supplying a real spinlock implementation is
|
||||
* probably far better.
|
||||
*/
|
||||
#define NUM_SPINLOCK_SEMAPHORES 1024
|
||||
|
||||
/*
|
||||
* Define this if you want to allow the lo_import and lo_export SQL
|
||||
* functions to be executed by ordinary users. By default these
|
||||
|
Reference in New Issue
Block a user