Re: Flushing large data immediately in pqcomm

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Flushing large data immediately in pqcomm
Дата
Msg-id CAApHDvoHJYcv+RCeaXM3VL6_44CgfjLLzvBbVAPvVLEMDxUdDA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Flushing large data immediately in pqcomm  (Jelte Fennema-Nio <postgres@jeltef.nl>)
Ответы Re: Flushing large data immediately in pqcomm  (Melih Mutlu <m.melihmutlu@gmail.com>)
Список pgsql-hackers
On Fri, 15 Mar 2024 at 02:03, Jelte Fennema-Nio <postgres@jeltef.nl> wrote:
>
> On Thu, 14 Mar 2024 at 13:12, Robert Haas <robertmhaas@gmail.com> wrote:
> >
> > On Thu, Mar 14, 2024 at 7:22 AM Melih Mutlu <m.melihmutlu@gmail.com> wrote:
> > > 1- Even though I expect both the patch and HEAD behave similarly in case of small data (case 1: 100 bytes), the
patchruns slightly slower than HEAD. 
> >
> > I wonder why this happens. It seems like maybe something that could be fixed.
>
> some wild guesses:
> 1. maybe it's the extra call overhead of the new internal_flush
> implementation. What happens if you make that an inline function?
> 2. maybe swap these conditions around (the call seems heavier than a
> simple comparison): !pq_is_send_pending() && len >= PqSendBufferSize

I agree these are both worth trying.  For #2, I wonder if the
pq_is_send_pending() call is even worth checking at all. It seems to
me that the internal_flush_buffer() code will just do nothing if
nothing is pending.  Also, isn't there almost always going to be
something pending when the "len >= PqSendBufferSize" condition is met?
 We've just added the msgtype and number of bytes to the buffer which
is 5 bytes. If the previous message was also more than
PqSendBufferSize, then the buffer is likely to have 5 bytes due to the
previous flush, otherwise isn't it a 1 in 8192 chance that the buffer
is empty?

If that fails to resolve the regression, maybe it's worth memcpy()ing
enough bytes out of the message to fill the buffer then flush it and
check if we still have > PqSendBufferSize remaining and skip the
memcpy() for the rest.  That way there are no small flushes of just 5
bytes and only ever the possibility of reducing the flushes as no
pattern should cause the number of flushes to increase.

David



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

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: Trying to build x86 version on windows using meson
Следующее
От: David Rowley
Дата:
Сообщение: Re: Flushing large data immediately in pqcomm