Re: About default inBufSize (connection read buffer size) in libpq

Lists: Postg토토 핫SQL :Postg메이저 토토 사이트SQL
From: Трофимов Иван <i(dot)trofimow(at)yandex(dot)ru>
To: "pgsql-interfaces(at)lists(dot)postgresql(dot)org" <pgsql-interfaces(at)lists(dot)postgresql(dot)org>
Subject: About default inBufSize (connection read buffer size) in libpq
Date: 2023-03-05 02:42:06
Message-ID: 298631677983213@mail.yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: Postg사설 토토 사이트SQL Postg토토 사이트 순위SQL

<div>Hi!</div><div> </div><div>I was running some benchmarks for PG driver built on top of libpq async functionality,</div><div>and noticed that recv syscalls issued by the application are limited by 16Kb, which seems to</div><div>be inBufSize coming from makeEmptyPGconn in interfaces/libpq/fe-connect.c.</div><div> </div><div>Hacking that to higher values allowed my benchmarks to issue drastically less syscalls</div><div>when running some heavy selects, both in local and cloud environments, which made them</div><div>significantly faster.</div><div> </div><div>I believe there is a reason for that value to be 16Kb, but i was wondering if it's safe to change</div><div>this default to user-provided value, and if it is - could this functionality be added into API?</div>

Attachment Content-Type Size
unknown_filename text/html 782 bytes

From: Andres Freund <andres(at)anarazel(dot)de>
To: Трофимов Иван <i(dot)trofimow(at)yandex(dot)ru>, pgsql-hackers(at)postgresql(dot)org
Cc: "pgsql-interfaces(at)lists(dot)postgresql(dot)org" <pgsql-interfaces(at)lists(dot)postgresql(dot)org>
Subject: Re: About default inBufSize (connection read buffer size) in libpq
Date: 2023-03-06 18:15:11
Message-ID: 20230306181511.kpje2skz2vhpqz3b@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: Postg토토 핫SQL : Postg메이저 토토 사이트SQL

Hi,

On 2023-03-05 05:42:06 +0300, Трофимов Иван wrote:
> I was running some benchmarks for PG driver built on top of libpq async
> functionality,
> and noticed that recv syscalls issued by the application are limited by 16Kb,
> which seems to
> be inBufSize coming from makeEmptyPGconn in interfaces/libpq/fe-connect.c.
>  
> Hacking that to higher values allowed my benchmarks to issue drastically less
> syscalls
> when running some heavy selects, both in local and cloud environments, which
> made them
> significantly faster.
>  
> I believe there is a reason for that value to be 16Kb, but i was wondering if
> it's safe to change
> this default to user-provided value, and if it is - could this functionality be
> added into API?

I've observed the small buffer size hurting as well - not just client side,
also on the serve.

But I don't think we necessarily need to make it configurable. From what I can
tell the pain mainly comes using the read/send buffers when they don't even
help, because the message data we're processing is bigger than the buffer
size. When we need to receive / send data that we know is bigger than the
the buffer, we should copy the portion that is still in the buffer, and then
send/receive directly from the data to be sent/received.

Greetings,

Andres Freund