Re: Restart pg_usleep when interrupted - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: Restart pg_usleep when interrupted
Date
Msg-id ZpGBjZZtbDGUtvTV@nathan
Whole thread Raw
In response to Re: Restart pg_usleep when interrupted  (Sami Imseih <samimseih@gmail.com>)
Responses Re: Restart pg_usleep when interrupted
List pgsql-hackers
On Fri, Jul 12, 2024 at 12:14:56PM -0500, Sami Imseih wrote:
> 1/ TimestampDifference has a dependency on gettimeofday, 
> while my proposal utilizes clock_gettime. There are old discussions
> that did not reach a conclusion comparing both mechanisms. 
> My main conclusion from these hacker discussions [1], [2] and other 
> online discussions on the topic is clock_gettime should replace
> getimeofday when possible. Precision is the main reason.
> 
> 2/ It no longer uses the remain time. I think the remain time
> is still required here. I did a unrealistic stress test which shows 
> the original proposal can handle frequent interruptions much better.

My comment was mostly about coding style and not about gettimeofday()
versus clock_gettime().  What does your testing show when you don't have
the extra check, i.e.,

    struct timespec delay;
    struct timespec remain;

    delay.tv_sec = microsec / 1000000L;
    delay.tv_nsec = (microsec % 1000000L) * 1000;

    while (nanosleep(&delay, &remain) == -1 && errno == EINTR)
        delay = remain;

-- 
nathan



pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: Amcheck verification of GiST and GIN
Next
From: Daniel Gustafsson
Date:
Subject: Re: Add support to TLS 1.3 cipher suites and curves lists