Re: Adjustment of spinlock sleep delays - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Adjustment of spinlock sleep delays
Date
Msg-id 13987.1060124527@sss.pgh.pa.us
Whole thread Raw
In response to Re: Adjustment of spinlock sleep delays  (Rod Taylor <rbt@rbt.ca>)
Responses Re: Adjustment of spinlock sleep delays
List pgsql-hackers
Rod Taylor <rbt@rbt.ca> writes:
> How about (round to nearest 10msec):

> time =3D oldtime + oldtime / 2 + oldtime * rand()

> while (time > 1 second)
>     time =3D time - 0.80sec

> This would stagger the wakeup times, and ensure a larger number of
> retries -- but the times should be large enough after the first few
> tries (larger than 200msec) that further backoff won't be required.

But after the first few tries the sleep time would always exceed
200msec, so there would be a *maximum* of 60*5 = 300 tries before
failing --- probably a lot less, like about 120 on average.

The random component should already help to scatter the wakeups pretty
well, so I'm thinking about just
if (oldtime > 1 sec)    time = 10msecelse    time = oldtime + oldtime * rand()

ie random growth of a maximum of 2x per try, and reset to minimum delay
when you get past 1 sec.  This would guarantee at least as many tries
as I'm getting currently with the deterministic algorithm (which is
effectively this if rand() always returned 1).
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: logging stuff
Next
From: "Mendola Gaetano"
Date:
Subject: Re: logging stuff