Re: [HACKERS] Re: [PATCHES] S_LOCK reduced contention through backoff patch

Bruce Momjian <maillist@candle.pha.pa.us>

From: Bruce Momjian <maillist@candle.pha.pa.us>
To: ocie@paracel.com
Cc: dg@illustra.com, scrappy@hub.org, pgsql-hackers@postgreSQL.org
Date: 1998-04-30T04:21:15Z
Lists: pgsql-hackers
> 
> David Gould wrote:
> 
> [snip]
> > Here is the Spinlock back off patch I promised. This does semi-random
> > backoff using select() to lessen throughput degradation due to spinlock
> > contention with large numbers of runnable backends.
> 
> Does this actually use some sort of random number generator?  I'm
> thinking that this may not be entirely necessary.  With Ethernet, this
> is needed to avoid another colission, but with locks, one process is
> guaranteed to get a lock.

>From the patch.  Looks very good to me.

!  * Each time we busy spin we select the next element of this array as the
!  * number of microseconds to wait. This accomplishes pseudo random back-off.
!  * Values are not critical and are weighted to the low end of the range. They
!  * were chosen to work even with different select() timer resolutions on
!  * different platforms.
!  * note: total time to cycle through all 16 entries might be about .1 second.
!  */
! int                   s_spincycle[S_NSPINCYCLE] =
! {0, 0, 0, 1000, 5000, 0, 10000, 3000,
!  0, 10000, 0, 15000, 9000, 21000, 6000, 30000
! };

-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)