Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hrVpf-0002c5-6f for pgsql-general@arkaria.postgresql.org; Sat, 27 Jul 2019 23:10:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hrVpd-0007nI-PC for pgsql-general@arkaria.postgresql.org; Sat, 27 Jul 2019 23:10:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hrVpd-0007nA-Cb for pgsql-general@lists.postgresql.org; Sat, 27 Jul 2019 23:10:29 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hrVpb-0000Ol-5d for pgsql-general@postgresql.org; Sat, 27 Jul 2019 23:10:28 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x6RNAMx2009503; Sat, 27 Jul 2019 19:10:22 -0400 From: Tom Lane To: Andres Freund cc: Artemiy Ryabinkov , pgsql-general@postgresql.org 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> Comments: In-reply-to Andres Freund message dated "Sat, 27 Jul 2019 15:58:54 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9501.1564269022.1@sss.pgh.pa.us> Date: Sat, 27 Jul 2019 19:10:22 -0400 Message-ID: <9502.1564269022@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2019-07-27 18:34:50 -0400, Tom Lane wrote: >> 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 think it is worth doing some testing, rather than just blindly changing buffer size, because we don't know how much we'd have to change it to have any useful effect. > 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. Maybe, but how often does a single putbytes call transfer more than 16K? (If you fill the existing buffer, but don't have a full bufferload left to transfer, I doubt you want to shove the fractional bufferload directly to the kernel.) Perhaps this added complexity will pay for itself, but I don't think we should just assume 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. Right, but then we pay for COW when a child process first touches it, no? Maybe the kernel is smart about pages that started as BSS, but I wouldn't bet on it. regards, tom lane