From: Nathan Bossart <nathandbossart@gmail.com>
To: Sami Imseih <samimseih@gmail.com>
Cc: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: Restart pg_usleep when interrupted
Date: Fri, 12 Jul 2024 14:18:37 -0500
Message-ID: <ZpGBjZZtbDGUtvTV@nathan> (raw)
In-Reply-To: <01A15AEA-C35C-41DF-8E81-3B5A0B523939@gmail.com>
References: <AC328D21-21D6-4FFC-8F6B-BFE9AD940524@gmail.com>
<ZoPC5IeP4k7sZpki@ip-10-97-1-34.eu-west-3.compute.internal>
<373D199B-2312-431D-8018-F2808913F979@gmail.com>
<Zo0UdeE3i9d0Wt5E@ip-10-97-1-34.eu-west-3.compute.internal>
<3712E898-03DA-4E03-AF51-D3E24DE68216@gmail.com>
<C18017A1-EDFD-4F2F-BCA1-0572D4CCC92B@gmail.com>
<Zo_7blmO166ZDGbW@nathan>
<2F781744-69B8-4BC2-A6EF-3998DCCDB634@gmail.com>
<ZpA4_Pw14FCP6025@nathan>
<01A15AEA-C35C-41DF-8E81-3B5A0B523939@gmail.com>
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
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: nathandbossart@gmail.com, samimseih@gmail.com, bertranddrouvot.pg@gmail.com, tgl@sss.pgh.pa.us, robertmhaas@gmail.com
Subject: Re: Restart pg_usleep when interrupted
In-Reply-To: <ZpGBjZZtbDGUtvTV@nathan>
References: <AC328D21-21D6-4FFC-8F6B-BFE9AD940524@gmail.com> <ZoPC5IeP4k7sZpki@ip-10-97-1-34.eu-west-3.compute.internal> <373D199B-2312-431D-8018-F2808913F979@gmail.com> <Zo0UdeE3i9d0Wt5E@ip-10-97-1-34.eu-west-3.compute.internal> <3712E898-03DA-4E03-AF51-D3E24DE68216@gmail.com> <C18017A1-EDFD-4F2F-BCA1-0572D4CCC92B@gmail.com> <Zo_7blmO166ZDGbW@nathan> <2F781744-69B8-4BC2-A6EF-3998DCCDB634@gmail.com> <ZpA4_Pw14FCP6025@nathan> <01A15AEA-C35C-41DF-8E81-3B5A0B523939@gmail.com> <ZpGBjZZtbDGUtvTV@nathan>
* 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