Re: Microsecond sleeps with select() - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Microsecond sleeps with select()
Date
Msg-id 4290.982434631@sss.pgh.pa.us
Whole thread Raw
In response to Re: Microsecond sleeps with select()  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Microsecond sleeps with select()
List pgsql-hackers
Bruce Momjian <pgman@candle.pha.pa.us> writes:
>> Having read the select(2) man page more closely, I now realize that
>> it is *defined* not to yield the processor when the requested delay
>> is zero: it just checks the file ready status and returns immediately.

> Actually, a kernel call is something.  On kernel call return, process
> priorities are checked and the CPU may be yielded to a higher-priority
> backend that perhaps just had its I/O completed.

So *if* some I/O just completed, the call *might* do what we need,
which is yield the CPU.  Otherwise we're just wasting cycles, and
will continue to waste them until we do a select with a nonzero
delay.  I propose we cut out the spinning and just do a nonzero delay
immediately.

> I think the 0 and 10000 are correct.  They would be zero ticks and one
> tick.  You think 5000 and 10000 would be better?  I can see that.

No, I am not suggesting that, because there is no difference between
5000 and 10000.

All of this stuff probably ought to be replaced with a less-bogus
mechanism (POSIX semaphores maybe?), but not in late beta.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Re: beta5 ...
Next
From: Bruce Momjian
Date:
Subject: Re: Microsecond sleeps with select()