Re: Avoiding roundoff error in pg_sleep() - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Avoiding roundoff error in pg_sleep()
Date
Msg-id 3942055.1758834345@sss.pgh.pa.us
Whole thread Raw
In response to Re: Avoiding roundoff error in pg_sleep()  (Nathan Bossart <nathandbossart@gmail.com>)
List pgsql-hackers
Nathan Bossart <nathandbossart@gmail.com> writes:
> Agreed, I'm not too worried about the system calls in this case.  I think I
> was more interested in seeing whether we could avoid the complicated float
> handling.  Something else that seems to work is moving the initial endtime
> calculation to within the loop, like so:

> -        delay = endtime - GetNowFloat();
> +        if (first)
> +        {
> +            endtime = GetNowFloat() + secs;
> +            delay = secs;
> +            first = false;
> +        }
> +        else
> +            delay = endtime - GetNowFloat();

Hmm ... I'm not sure I'd trust that to give the right answer
if WaitLatch is interrupted so that we have to recalculate
the delay.

> But, in any case, your patch still LGTM.

Pushed it.  Again, thanks for reviewing!

            regards, tom lane



pgsql-hackers by date:

Previous
From: "Matheus Alcantara"
Date:
Subject: Remove unused parameter on check_and_push_window_quals
Next
From: "Joel Jacobson"
Date:
Subject: Re: Optimize LISTEN/NOTIFY