mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Improve spinlock code for recent x86 processors: insert a PAUSE
instruction in the s_lock() wait loop, and use test before test-and-set in TAS() macro to avoid unnecessary bus traffic. Patch from Manfred Spraul, reworked a bit by Tom.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.22 2003/12/23 22:15:07 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.23 2003/12/27 20:58:58 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -88,6 +88,10 @@ s_lock(volatile slock_t *lock, const char *file, int line)
|
||||
|
||||
while (TAS(lock))
|
||||
{
|
||||
/* CPU-specific delay each time through the loop */
|
||||
SPIN_DELAY();
|
||||
|
||||
/* Block the process every SPINS_PER_DELAY tries */
|
||||
if (++spins > SPINS_PER_DELAY)
|
||||
{
|
||||
if (++delays > NUM_DELAYS)
|
||||
|
Reference in New Issue
Block a user