Configurable Send/Receive Buffer Sizes

Lists: pgsql-jdbc
From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Configurable Send/Receive Buffer Sizes
Date: 2011-04-21 14:42:07
Message-ID: 88D436FBC188677633204A9D@apophis.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Folks,

please find attached a patch which allows to specify the size of TCP
send/receive buffers (SO_SNDBUF/SO_RECVBUF socket options) in the JDBC driver.

The patch adds two connection parameters to the JDBC driver:

send_buffer_size: Specifes the size of the TCP write buffer used with the
connection

receive_buffer_size: Specifies the size of the TCP read buffer used with the
connection

For example:

Connection conn =
DriverManager.getConnection("jdbc:postgresql://localhost:5432/bernd?loglevel=2&send_buffer_size=262144&receive_buffer_size=1048576",
"bernd", "");

It occured to me several times now where this functionality became useful,
especially when working on migration projects in the past, where the
application couldn't be changed immediately when doing large batch processing.
An interesting example is the small test program from

<http://archives.postgresql.org/pgsql-jdbc/2008-10/msg00045.php>

which could be make working with the appropiate buffer settings.

Maybe this is worth for discussion or even to investigate it further for
inclusion.

Note that on Linux you need to adjust the kernel maximum buffer sizes in
/proc/sys/net/core/wmem_max and /proc/sys/net/core/rmem_max to become any
settings effective. I have reports that this isn't necessary on Windows,
however. This certainly needs adequate documentation.

I didn't invest any time on benchmarks, but maybe there's also some value in it
performance-wise.

--
Thanks

Bernd

Attachment Content-Type Size
pgjdbc_buffer_sizes.patch application/octet-stream 6.0 KB

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Bernd Helmle" <mailings(at)oopsware(dot)de>,<pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Configurable Send/Receive Buffer Sizes
Date: 2011-04-21 14:49:54
Message-ID: 4DAFFDC2020000250003CB29@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Bernd Helmle <mailings(at)oopsware(dot)de> wrote:

> An interesting example is the small test program from
>
> <http://archives.postgresql.org/pgsql-jdbc/2008-10/msg00045.php>
>
> which could be make working with the appropiate buffer settings.

> I didn't invest any time on benchmarks, but maybe there's also
> some value in it performance-wise.

So the primary point is to avoid deadlocks on full network buffers?

-Kevin


From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Configurable Send/Receive Buffer Sizes
Date: 2011-04-21 15:16:23
Message-ID: 4367E2F169C261E772635FE8@apophis.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

--On 21. April 2011 09:49:54 -0500 Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
wrote:

> Bernd Helmle <mailings(at)oopsware(dot)de> wrote:
>
>> An interesting example is the small test program from
>>
>> <http://archives.postgresql.org/pgsql-jdbc/2008-10/msg00045.php>
>>
>> which could be make working with the appropiate buffer settings.
>
>> I didn't invest any time on benchmarks, but maybe there's also
>> some value in it performance-wise.
>
> So the primary point is to avoid deadlocks on full network buffers?
>

Yeah, that was the primary idea...or, well, to workaround them. You could argue
that its still possible to run into those issue, but less likely. With the
proper settings it didn't occur to me again, though.

--
Thanks

Bernd


From: Daniel Migowski <dmigowski(at)ikoffice(dot)de>
To: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Configurable Send/Receive Buffer Sizes
Date: 2011-04-27 12:02:40
Message-ID: 41ED3F5450C90F4D8381BC4D8DF6BBDC4F099DF1@EXCHANGESERVER.ikoffice.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

I fully support this request! I currently have a overridden PGStream in my Classpath to be able to set it manually to 128k. Else our update scripts hang for the same reason. Making this configurable would be of great help.

Regards,
Daniel Migowski

________________________________________
Von: pgsql-jdbc-owner(at)postgresql(dot)org [pgsql-jdbc-owner(at)postgresql(dot)org]&quot; im Auftrag von &quot;Bernd Helmle [mailings(at)oopsware(dot)de]
Gesendet: Donnerstag, 21. April 2011 17:16
An: Kevin Grittner; pgsql-jdbc(at)postgresql(dot)org
Betreff: Re: [JDBC] Configurable Send/Receive Buffer Sizes

--On 21. April 2011 09:49:54 -0500 Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
wrote:

> Bernd Helmle <mailings(at)oopsware(dot)de> wrote:
>
>> An interesting example is the small test program from
>>
>> <http://archives.postgresql.org/pgsql-jdbc/2008-10/msg00045.php>
>>
>> which could be make working with the appropiate buffer settings.
>
>> I didn't invest any time on benchmarks, but maybe there's also
>> some value in it performance-wise.
>
> So the primary point is to avoid deadlocks on full network buffers?
>

Yeah, that was the primary idea...or, well, to workaround them. You could argue
that its still possible to run into those issue, but less likely. With the
proper settings it didn't occur to me again, though.

--
Thanks

Bernd

--
Sent via pgsql-jdbc mailing list (pgsql-jdbc(at)postgresql(dot)org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc


From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Bernd Helmle <mailings(at)oopsware(dot)de>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Configurable Send/Receive Buffer Sizes
Date: 2011-08-10 17:29:42
Message-ID: CADK3HHJ9TCQNxoTX24KHrkkvwaGuBvhwXp3hy4i+E1XfDomEgA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Is there any objection to this patch ?

Otherwise I will look at committing it .

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

On Thu, Apr 21, 2011 at 10:42 AM, Bernd Helmle <mailings(at)oopsware(dot)de> wrote:
> Folks,
>
> please find attached a patch which allows to specify the size of TCP
> send/receive buffers (SO_SNDBUF/SO_RECVBUF socket options) in the JDBC
> driver.
>
> The patch adds two connection parameters to the JDBC driver:
>
> send_buffer_size: Specifes the size of the TCP write buffer used with the
> connection
>
> receive_buffer_size: Specifies the size of the TCP read buffer used with the
> connection
>
> For example:
>
> Connection conn =
> DriverManager.getConnection("jdbc:postgresql://localhost:5432/bernd?loglevel=2&send_buffer_size=262144&receive_buffer_size=1048576",
> "bernd", "");
>
> It occured to me several times now where this functionality became useful,
> especially when working on migration projects in the past, where the
> application couldn't be changed immediately when doing large batch
> processing. An interesting example is the small test program from
>
> <http://archives.postgresql.org/pgsql-jdbc/2008-10/msg00045.php>
>
> which could be make working with the appropiate buffer settings.
>
> Maybe this is worth for discussion or even to investigate it further for
> inclusion.
>
> Note that on Linux you need to adjust the kernel maximum buffer sizes in
> /proc/sys/net/core/wmem_max and /proc/sys/net/core/rmem_max to become any
> settings effective. I have reports that this isn't necessary on Windows,
> however.  This certainly needs adequate documentation.
>
> I didn't invest any time on benchmarks, but maybe there's also some value in
> it performance-wise.
>
> --
> Thanks
>
>        Bernd
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>
>