Re: pgstat_send_connstats() introduces unnecessary timestamp and UDP overhead

Поиск
Список
Период
Сортировка
От Kyotaro Horiguchi
Тема Re: pgstat_send_connstats() introduces unnecessary timestamp and UDP overhead
Дата
Msg-id 20210825.101241.866815796453383011.horikyota.ntt@gmail.com
обсуждение исходный текст
Ответ на Re: pgstat_send_connstats() introduces unnecessary timestamp and UDP overhead  (Laurenz Albe <laurenz.albe@cybertec.at>)
Список pgsql-hackers
At Tue, 24 Aug 2021 12:34:25 +0200, Laurenz Albe <laurenz.albe@cybertec.at> wrote in 
> On Tue, 2021-08-24 at 15:12 +0900, Kyotaro Horiguchi wrote:
> > 
> > - remove redundant gettimeofday().
> > - avoid sending dedicate UCP packet for connection stats.
> 
> Thank you.
> 
> Perhaps I misread that, but doesn't that mean that the session statistics
> could be sent several times?  "pgstat_send_tabstat()" could be called more than
> once, right?

Yes, it can be called two or more times for a call to
pgstat_report_stat, but the patch causes only the first of them convey
effective connection stats numbers. This is the same way as how
transaction stats are treated.  If no table activities have taken
place at all, pgStatXactCommit/Rollback are not consumed then the
following condition:

>    /*
>     * Send partial messages.  Make sure that any pending xact commit/abort
>     * gets counted, even if there are no table stats to send.
>     */
>    if (regular_msg.m_nentries > 0 ||
>        pgStatXactCommit > 0 || pgStatXactRollback > 0)

leads to a call to pgstat_send_tabstat() and it sends a tabstat
message without a table stats, which is a "partial message".

In this logic the condition term (pgStatXactCommit > 0 ||
pgStatXactRollback > 0) acts as a single-shot trigger.

So we can piggy-back on the condition to send something only once.

The patch sets "0" = (DISCONNECT_NOT_YET) to m_disconnect as the
"not-effective" number, but it would be better to add
DISCONNECT_something to express that state.

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Fujii Masao
Дата:
Сообщение: Re: Some leftovers of recent message cleanup?
Следующее
От: Kyotaro Horiguchi
Дата:
Сообщение: Re: Some leftovers of recent message cleanup?