Re: pg_stat_io for the startup process
От | Kyotaro Horiguchi |
---|---|
Тема | Re: pg_stat_io for the startup process |
Дата | |
Msg-id | 20230428.114348.519597625859326132.horikyota.ntt@gmail.com обсуждение исходный текст |
Ответ на | Re: pg_stat_io for the startup process (Kyotaro Horiguchi <horikyota.ntt@gmail.com>) |
Список | pgsql-hackers |
At Fri, 28 Apr 2023 11:15:51 +0900 (JST), Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote in > At Thu, 27 Apr 2023 17:30:40 -0400, Melanie Plageman <melanieplageman@gmail.com> wrote in > > After a quick example implementation of this, I found that it seemed to > > try and flush the stats less often on an idle standby (good) than using > > enable_timeout_every(). > > Just rearming with the full-interval will work that way. Our existing > strategy for this is seen in PostgresMain(). > > stats_timeout = pgstat_report_stat(false); > if (stats_timeout > 0) > { > if (!get_timeout_active(BLAH_TIMEOUT)) > enable_timeout_after(BLAH_TIMEOUT, stats_timeout); > } > else > { > if (get_timeout_active(BLAH_TIMEOUT)) > disable_timeout(BLAH_TIMEOUT, false); > } > WaitLatch(); Im my example, I left out idle-time flushing, but I realized we don't need the timeout mechanism here since we're already managing it. So the following should work (assuming the timestamp updates with GetCurrentTimestamp() in my last patch). @@ -3889,13 +3900,23 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, /* Update pg_stat_recovery_prefetch before sleeping. */ XLogPrefetcherComputeStats(xlogprefetcher); + /* + * Report stats; if not time yet, set next WaitLatch to + * wake up at the next reporing time. + */ + wait_time = pgstat_report_stat(false); + + /* if no pending stats, sleep forever */ + if (wait_time == 0) + wait_time = -1L; + /* * Wait for more WAL to arrive, when we will be woken * immediately by the WAL receiver. */ (void) WaitLatch(&XLogRecoveryCtl->recoveryWakeupLatch, WL_LATCH_SET | WL_EXIT_ON_PM_DEATH, - -1L, + wait_time, WAIT_EVENT_RECOVERY_WAL_STREAM); regards. -- Kyotaro Horiguchi NTT Open Source Software Center
Вложения
В списке pgsql-hackers по дате отправления: