Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pZFuL-00088K-8I for pgsql-interfaces@arkaria.postgresql.org; Mon, 06 Mar 2023 18:50:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pZFuK-00072d-6R for pgsql-interfaces@arkaria.postgresql.org; Mon, 06 Mar 2023 18:50:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pZFMn-0004uP-45 for pgsql-interfaces@lists.postgresql.org; Mon, 06 Mar 2023 18:15:22 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pZFMj-0002m8-9G for pgsql-interfaces@lists.postgresql.org; Mon, 06 Mar 2023 18:15:19 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 2452D5C005F; Mon, 6 Mar 2023 13:15:13 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 06 Mar 2023 13:15:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1678126513; x=1678212913; bh=dlhxTBkSF8u6m0co03VYTBfA6VVtlL6Sh2W j5WsKQzc=; b=IU/XcdZGSBBg6ZzvC5VrChPxJgcnJulukNRTfzF7rwPIYE8D3HV YCXNDamvcCCw8oEhArIqn3jmzZoLUaty65s1/RkPgcGWkS23muh0+BN0rMarxI7F SHGqiXIoZnnia4vKFUiDQ5lSE006Me8CGicsDdSljliq7f+MQ84IHmlMp/I0Dy71 yEiaWJJsVfojtW4SjPusjBeXYMuDzIovxL0+hT2XNbyrEpaSrgl9h5y7+SQ/PHT9 ZjHH2Ahb1m7kgqLT5JrzjVTR9dTy8zJTgGaG3lB+/7X5eMY3qPsb72TBqM38gpk0 CHfYf+sY7h98wh1DiqPn03VmwaEaw8TWu5g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1678126513; x=1678212913; bh=dlhxTBkSF8u6m0co03VYTBfA6VVtlL6Sh2W j5WsKQzc=; b=QqyH5Dog61DGdvx5X9Bj8MSC1w9rk7uvLBpIZUaMDWALhrvESyG fHzCh2AdJXEgZLCLnOBO9C2Mir2UCEvgHhFAfs3Mj/Bm8vpXzlje2QHF4i0h2E+3 vRUCcXVStm3NM/Yz+rmD5SJ43XAVTx91A0ZuVXs3SZUyUqFZ08o/QbNTDKnkT3L3 GKq/+c4A2CTUNYEaZl2jchJy+JEzxx1kprIXT85BdVexLbNWTdmbUVlTtxN0PhRF Ji1fkWeB0+lZT3BF7Jo+e2gObaipujt6kdM8ncJC+Sed0n5uhOs6CnH1dFiStYuj md9Ap2RA7qTE4yIIq+cxxN+1sHGPSQzygrw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvddtkedgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtugfgjgesth ekredttddtjeenucfhrhhomheptehnughrvghsucfhrhgvuhhnugcuoegrnhgurhgvshes rghnrghrrgiivghlrdguvgeqnecuggftrfgrthhtvghrnhephfeitefgleevtedtffejve dujeekjedugfdtveffjeelvddtfeekgefgjefhgfegnecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdrug gv X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 6 Mar 2023 13:15:12 -0500 (EST) Date: Mon, 6 Mar 2023 10:15:11 -0800 From: Andres Freund To: =?utf-8?B?0KLRgNC+0YTQuNC80L7QsiDQmNCy0LDQvQ==?= , pgsql-hackers@postgresql.org Cc: "pgsql-interfaces@lists.postgresql.org" Subject: Re: About default inBufSize (connection read buffer size) in libpq Message-ID: <20230306181511.kpje2skz2vhpqz3b@awork3.anarazel.de> References: <298631677983213@mail.yandex.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <298631677983213@mail.yandex.ru> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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