Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sKkAv-00BrH8-Bk for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Jun 2024 19:43:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sKkAt-008RJu-46 for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Jun 2024 19:43:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sKkAs-008RJj-QX for pgsql-hackers@lists.postgresql.org; Fri, 21 Jun 2024 19:43:55 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sKkAp-002sMd-UT for pgsql-hackers@lists.postgresql.org; Fri, 21 Jun 2024 19:43:53 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 45LJhlk4640300; Fri, 21 Jun 2024 15:43:48 -0400 From: Tom Lane To: Jelte Fennema-Nio cc: =?UTF-8?B?0JTQvNC40YLRgNC40Lkg0J/QuNGC0LDQutC+0LI=?= , pgsql-hackers@lists.postgresql.org Subject: Re: Small LO_BUFSIZE slows down lo_import and lo_export in libpq In-reply-to: References: Comments: In-reply-to Jelte Fennema-Nio message dated "Fri, 21 Jun 2024 14:07:21 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <640298.1718999027.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 21 Jun 2024 15:43:47 -0400 Message-ID: <640299.1718999027@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jelte Fennema-Nio writes: > On Fri, 21 Jun 2024 at 10:46, =D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9= =D0=9F=D0=B8=D1=82=D0=B0=D0=BA=D0=BE=D0=B2 wrote: >> Why not increase the buffer size? > I think changing the buffer size sounds like a reasonable idea, if > that speeds stuff up. But I think it would greatly help your case if > you showed the perf increase using a simple benchmark, especially if > people could run this benchmark on their own machines to reproduce. Yeah. "Why not" is not a patch proposal, mainly because the correct question is "what other size are you proposing?" This is not something that we can just randomly whack around, either. Both lo_import_internal and lo_export assume they can allocate the buffer on the stack, which means you have to worry about available stack space. As a concrete example, I believe that musl still defaults to 128kB thread stack size, which means that a threaded client program on that platform would definitely fail with = LO_BUFSIZE >=3D 128kB, and even 64kB would be not without risk. We could dodge that objection by malloc'ing the buffer, which might be a good thing to do anyway because it'd improve the odds of getting a nicely-aligned buffer. But then you have to make the case that the extra malloc and free isn't a net loss, which it could be for not-very-large transfers. So bottom line is that you absolutely need a test case whose performance can be measured under different conditions. regards, tom lane