Re: Adjustment of spinlock sleep delays

From: Rod Taylor <rbt(at)rbt(dot)ca>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Adjustment of spinlock sleep delays
Date: 2003-08-05 22:47:56
Message-ID: 1060123675.19206.12.camel@jester
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 2003-08-05 at 18:19, Tom Lane wrote:
> Rod Taylor <rbt(at)rbt(dot)ca> writes:
> > After the first few sleeps should it add a random() element to the delay
> > time?
>
> Hmm, that's a thought --- but how big a random element?
>
> Fooling with the original idea, I'm having trouble with getting both
> plausible backoff and a reasonable number of attempts before failing.
> I tried the sequence
>
> 10 msec, 20 msec, 40, 80, ..., 1280 (1.28 sec), repeat
>
> but this only gives a couple of hundred tries before one minute has
> elapsed, which seems uncomfortably low. Maybe there's no alternative,
> though, if we want any good-sized delays in there.

How about (round to nearest 10msec):

time = oldtime + oldtime / 2 + oldtime * rand()

while (time > 1 second)
time = 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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2003-08-05 22:50:06 Re: logging stuff
Previous Message Tom Lane 2003-08-05 22:41:37 Re: TODO: trigger features