Re: Sub-millisecond [autovacuum_]vacuum_cost_delay broken
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Nathan Bossart <nathandbossart@gmail.com>,
Melanie Plageman <melanieplageman@gmail.com>, Pg Hackers <pgsql-hackers@postgresql.org>, Stephen Frost <sfrost@snowman.net>
Date: 2023-03-10T01:13:14Z
Lists: pgsql-hackers
On Fri, Mar 10, 2023 at 1:46 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: > >> I propose therefore that instead of increasing vacuum_cost_limit, > >> what we ought to be doing is reducing vacuum_cost_delay by a similar > >> factor. And, to provide some daylight for people to reduce it even > >> more, we ought to arrange for it to be specifiable in microseconds > >> not milliseconds. There's no GUC_UNIT_US right now, but it's time. > > That last point was later overruled in favor of keeping it measured in > msec to avoid breaking existing configuration files. Nonetheless, > vacuum_cost_delay *is* an actual time to wait (conceptually at least), > not just part of a unitless ratio; and there seem to be good arguments > in favor of letting people make it small. > > I take your point that really short sleeps are inefficient so far as the > scheduling overhead goes. But on modern machines you probably have to get > down to a not-very-large number of microseconds before that's a big deal. OK. One idea is to provide a WaitLatchUsec(), which is just some cross platform donkeywork that I think I know how to type in, and it would have to round up on poll() and Windows builds. Then we could either also provide WaitEventSetResolution() that returns 1000 or 1 depending on availability of 1us waits so that we could round appropriately and then track residual, but beyond that let the user worry about inaccuracies and overheads (as mentioned in the documentation), or we could start consulting the clock and tracking our actual sleep time and true residual over time (maybe that's what "closed-loop control" means?).
Commits
-
Use nanosleep() to implement pg_usleep().
- a948e49e2ef1 16.0 landed
-
Update obsolete comment about pg_usleep() accuracy.
- e4da2a44c17a 16.0 landed
-
Fix fractional vacuum_cost_delay.
- 2bef57ee8b38 14.8 landed
- d9c9c43af5c8 15.3 landed
- 720de00af49d 16.0 landed