| From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Avoiding roundoff error in pg_sleep() |
| Date: | 2025-09-25 19:46:40 |
| Message-ID: | aNWcIJ1qT0gEWpda@nathan |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Thu, Sep 25, 2025 at 02:42:32PM -0400, Tom Lane wrote:
> Anyway, I propose trying to get rid of this misbehavior by avoiding
> floating point in the delay computation, as attached. With this
> patch I get less surprising behavior:
>
> [...]
>
> The code is a little more tied to TimestampTz being measured in
> microseconds than it was before, but it wouldn't really be much
> harder to fix if we ever change that.
LGTM. I considered suggesting initializing the delay before the loop and
then updating it at the end of the loop, but that moves the
CHECK_FOR_INTERRUPTS between the delay calculation and the WaitLatch(),
which seems like it might extend the sleeps a bit (although that might be
negligible in practice). Otherwise, the code seems to match
float8_timestamptz() somewhat closely, although I doubt it's worth trying
to unify the implementations.
--
nathan
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andreas Lind | 2025-09-25 20:10:04 | Re: Per-role disabling of LEAKPROOF requirements for row-level security? |
| Previous Message | Tom Lane | 2025-09-25 19:44:34 | Re: Avoiding roundoff error in pg_sleep() |