From: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
---|---|
To: | Sami Imseih <samimseih(at)gmail(dot)com> |
Cc: | Nathan Bossart <nathandbossart(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Restart pg_usleep when interrupted |
Date: | 2024-07-30 06:31:34 |
Message-ID: | ZqiIxptiTDqRTxDx@ip-10-97-1-34.eu-west-3.compute.internal |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On Mon, Jul 29, 2024 at 06:15:49PM -0500, Sami Imseih wrote:
> > On Jul 26, 2024, at 3:27 AM, Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
> > 3 ===
> >
> > I gave more thoughts and I think it can be simplified a bit to reduce the
> > number of operations in the while loop.
> >
> > What about relying on a "absolute" time that way:
> >
> > instr_time absolute;
> > absolute.ticks = start_time.ticks + msec * 1000000;
> >
> > and then in the while loop:
> >
> > while (nanosleep(&delay, &remain) == -1 && errno == EINTR)
> > {
> > instr_time current_time;
> > INSTR_TIME_SET_CURRENT(current_time);
> >
> > if (current_time.ticks > absolute.ticks)
> > {
> > break;
>
> While I agree this code is cleaner, myy hesitation there is we don’t
> have any other place in which we access .ticks directly and the
> common practice is to use the intsr_time.h APIs.
yeah, we already have a few macros that access the .ticks, so maybe we could add
2 new ones, say:
1. INSTR_TIME_ADD_MS(t1, msec)
2. INSTR_TIME_IS_GREATER(t1, t2)
I think the less operations is done in the while loop the better.
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
From | Date | Subject | |
---|---|---|---|
Next Message | Li, Yong | 2024-07-30 06:48:26 | Re: Separate HEAP WAL replay logic into its own file |
Previous Message | Yugo NAGATA | 2024-07-30 06:30:57 | Re: psql: Add leakproof field to \dAo+ meta-command results |