pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Use nanosleep(2) in pg_usleep, if available?
Date: Tue, 12 Mar 2019 13:36:21 -0400
Message-ID: <9875.1552412181@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmoZQrn=9wpSa25zn3pXQ+GM+hUoQSf_2-dN8F3G+t5BCJA@mail.gmail.com>
References: <4902.1552349020@sss.pgh.pa.us>
	<CA+TgmobkuSFwu9yvL5UxPrY-4OgFc5--p0os=qy8BHmfjGPWGg@mail.gmail.com>
	<9173.1552410822@sss.pgh.pa.us>
	<CA+TgmoZQrn=9wpSa25zn3pXQ+GM+hUoQSf_2-dN8F3G+t5BCJA@mail.gmail.com>

Robert Haas <robertmhaas@gmail.com> writes:
> On Tue, Mar 12, 2019 at 1:13 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> (I'm not sure what I think about which behavior is really more
>> desirable.  We can debate that if there's actually a plausible
>> choice to be made, which seems to depend on Windows.)

> Yeah, that's a fair question.  My motivation for asking was that I
> sometimes try to insert sleeps when debugging things, and they don't
> actually sleep, because they get interrupted.  That's not dispositive,
> though.

There never has been a guarantee that we won't sleep for *more*
than the requested time; the kernel might not give us back the
CPU right away.  But re-sleeping would at least ensure that
we won't sleep for *less* than the requested time.  So my opinion
after five minutes' thought is that re-sleeping is better, because
it gives you at least some kind of promise related to the function's
nominal semantics.

It still depends on whether we can make Windows do it, though.
I suppose a brute-force way would be like what WaitLatch does:
do our own timekeeping using instr_time.h.  (That'd work for
select as well, I guess.)

			regards, tom lane




view thread (7+ messages)  latest in thread

Message-ID: <9875.1552412181@sss.pgh.pa.us>
Permalink:  ../9875.1552412181@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/9875.1552412181@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com
  Subject: Re: Use nanosleep(2) in pg_usleep, if available?
  In-Reply-To: <9875.1552412181@sss.pgh.pa.us>
  References: <4902.1552349020@sss.pgh.pa.us> <CA+TgmobkuSFwu9yvL5UxPrY-4OgFc5--p0os=qy8BHmfjGPWGg@mail.gmail.com> <9173.1552410822@sss.pgh.pa.us> <CA+TgmoZQrn=9wpSa25zn3pXQ+GM+hUoQSf_2-dN8F3G+t5BCJA@mail.gmail.com> <9875.1552412181@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox