pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Artemiy Ryabinkov <getlag@ya.ru>
Cc: pgsql-general@postgresql.org
Subject: Re: Why does backend send buffer size hardcoded at 8KB?
Date: Sat, 27 Jul 2019 15:58:54 -0700
Message-ID: <20190727225854.w2f2e5n6lepqbbui@alap3.anarazel.de> (raw)
In-Reply-To: <762.1564266890@sss.pgh.pa.us>
References: <0cdc5485-cb3c-5e16-4a46-e3b2f7a41322@ya.ru>
	<20190727205243.l5xyhsg2y7aasgdd@alap3.anarazel.de>
	<762.1564266890@sss.pgh.pa.us>

Hi,

On 2019-07-27 18:34:50 -0400, Tom Lane wrote:
> Andres Freund <andres@anarazel.de> writes:
> > It might be better to just use larger send sizes however. I think most
> > kernels are going to be better than us knowing how to chop up the send
> > size.

> Yeah.  The existing commentary about that is basically justifying 8K
> as being large enough to avoid performance issues; if somebody can
> show that that's not true, I wouldn't have any hesitation about
> kicking it up.

You think that unnecessary fragmentation, which I did show, isn't good
enough? That does have cost on the network level, even if it possibly
doesn't show up that much in timing.


I wonder if we ought to just query SO_SNDBUF/SO_RCVBUF or such, and use
those (although that's not quite perfect, because there's some added
overhead before data ends up in SNDBUF). Probably with some clamping, to
defend against a crazy sysadmin setting it extremely high.


Additionally we perhaps ought to just not use the send buffer when
internal_putbytes() is called with more data than can fit in the
buffer. We should fill it with as much data as fits in it (so the
pending data like the message header, or smaller previous messages, are
flushed out in the largest size), and then just call secure_write()
directly on the rest. It's not free to memcpy all that data around, when
we already have a buffer.


> (Might be worth malloc'ing it rather than having it as part of the
> static process image if we do so, but that's a trivial change.)

We already do for the send buffer, because we repalloc it in
socket_putmessage_noblock(). Olddly enough we never reduce it's size
after that...

While the receive side is statically allocated, I don't think it ends up
in the process image as-is - as the contents aren't initialized, it ends
up in .bss.

Greetings,

Andres Freund





view thread (9+ messages)  latest in thread

Message-ID: <20190727225854.w2f2e5n6lepqbbui@alap3.anarazel.de>
Permalink:  ../20190727225854.w2f2e5n6lepqbbui@alap3.anarazel.de/
Also on:    postgresql.org/message-id/20190727225854.w2f2e5n6lepqbbui@alap3.anarazel.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: andres@anarazel.de, tgl@sss.pgh.pa.us, getlag@ya.ru
  Subject: Re: Why does backend send buffer size hardcoded at 8KB?
  In-Reply-To: <20190727225854.w2f2e5n6lepqbbui@alap3.anarazel.de>
  References: <0cdc5485-cb3c-5e16-4a46-e3b2f7a41322@ya.ru> <20190727205243.l5xyhsg2y7aasgdd@alap3.anarazel.de> <762.1564266890@sss.pgh.pa.us> <20190727225854.w2f2e5n6lepqbbui@alap3.anarazel.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox