Re: Restart pg_usleep when interrupted

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: 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-11 15:15:41
Message-ID: 3712E898-03DA-4E03-AF51-D3E24DE68216@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> I did a few tests with the patch and did not see any "large" drifts like the
> ones observed above.

Thanks for testing.

> I think it could be "simplified" by making use of instr_time instead of timespec
> for current and absolute. Then I think it would be enough to compare their
> ticks.

Correct I attached a v2 of this patch that uses instr_time to check the elapsed
time and break out of the loop. It needs some more benchmarking.

>> Since sub-millisecond sleep times are not guaranteed as suggested by
>> the vacuum_cost_delay docs ( see below ), an alternative idea
>> is to use clock_nanosleep for vacuum delay when it’s available, else
>> fallback to WaitLatch.
>
> Wouldn't that increase even more the cases where sub-millisecond won't be
> guaranteed?

Yes, nanosleep is going to provide the most coverage as it’s widely available.

Regards,

Sami

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2024-07-11 15:19:22 Re: Restart pg_usleep when interrupted
Previous Message cca5507 2024-07-11 14:09:13 Re: Redundant syscache access in get_rel_sync_entry()