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 1hrVeX-0002D7-Qf for pgsql-general@arkaria.postgresql.org; Sat, 27 Jul 2019 22:59:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hrVeW-000074-Lm for pgsql-general@arkaria.postgresql.org; Sat, 27 Jul 2019 22:59:00 +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 1hrVeW-00006v-9V for pgsql-general@lists.postgresql.org; Sat, 27 Jul 2019 22:59:00 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hrVeT-0000Jj-VH for pgsql-general@postgresql.org; Sat, 27 Jul 2019 22:58:59 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 4413A210AC; Sat, 27 Jul 2019 18:58:57 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sat, 27 Jul 2019 18:58:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to:from; s=fm2; bh=MBiWs5uz7tIIwNnSGvzJyP 51Tx5aobrpuKAKStVaS4c=; b=XDNuK3C/ImQXiY2RpDmAuuKWC+Lk/0d1UDhtcE aOUxpN0HBIosqEvbhn3LYk8l1vHR2vzhvM33INizbEb/+DZ+ZaYHmWIFoCd877FQ SMEcaIJIs2jZ0S5sRCxwnC0LJAA/mmHsFJ9P8QZgb2C+uQzvJx/h8fW4l7p/Whp3 Lfa9Rxtr3J2NU+b3qms+AOPX5kFojyy2jJXnuZdXZl3Pc3tsidpO7dxP7v2cI/xq b2XYew9yWPsAQVKLdQb8myE+L4gS2L2rCgbzb6aK3C11yU7ecl46Z7IwDiAcSKOs OPCZmCOU9MK38aLUSPKMgiHwBcpxERdDddRWG2D/cMlRnTYg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=MBiWs5 uz7tIIwNnSGvzJyP51Tx5aobrpuKAKStVaS4c=; b=wa0nj+ZEvPZdGbpI/4os6L Ih+8eXnoo86t5hkN6m+YieV+sRlVBXQQ59JbwGx7gmUgF7B+vh5yJKznipuLpbFj m9onGxtXd54bxGJ5JcA1WKdKnMOPygyGc0gIWwtY+9JaEHuLMdcRD3Njd1R9meOY D2CjY1pl39ufhtoRM3Kc/lgKPDD8kDKQcP2uwbVMSBGUcJnkUCYjYwB0algvWBi1 H0h5ghQl5LQVnXg30e2S/GHj+63Jz3YcCaxn6sa7jULiwWQ8uR/7YaXCCf/Us/eA 5Jg8oTBege7WZu/84kNuKx94mMqDrckJcKPDhpMFa/adTeUaj5GvqQIb2HVnbkHQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrkeejgddtgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffvuffkfhggtggujgfhsehttdertd dttddvnecuhfhrohhmpeetnhgurhgvshcuhfhrvghunhguuceorghnughrvghssegrnhgr rhgriigvlhdruggvqeenucfkphepieejrdduiedtrddvudekrddvfeejnecurfgrrhgrmh epmhgrihhlfhhrohhmpegrnhgurhgvshesrghnrghrrgiivghlrdguvgenucevlhhushht vghrufhiiigvpedt X-ME-Proxy: Received: from intern.anarazel.de (c-67-160-218-237.hsd1.ca.comcast.net [67.160.218.237]) by mail.messagingengine.com (Postfix) with ESMTPA id 3624680060; Sat, 27 Jul 2019 18:58:56 -0400 (EDT) Date: Sat, 27 Jul 2019 15:58:54 -0700 To: Tom Lane Cc: Artemiy Ryabinkov , pgsql-general@postgresql.org Subject: Re: Why does backend send buffer size hardcoded at 8KB? Message-ID: <20190727225854.w2f2e5n6lepqbbui@alap3.anarazel.de> References: <0cdc5485-cb3c-5e16-4a46-e3b2f7a41322@ya.ru> <20190727205243.l5xyhsg2y7aasgdd@alap3.anarazel.de> <762.1564266890@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <762.1564266890@sss.pgh.pa.us> g65;5402;1cFrom: Andres Freund From: Andres Freund List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2019-07-27 18:34:50 -0400, Tom Lane wrote: > Andres Freund 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