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 1r2SB5-00Gncf-8W for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Nov 2023 08:20:15 +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 1r2SB3-00Dlzk-QH for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Nov 2023 08:20:13 +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 1r2SB3-00Dlzc-By for pgsql-hackers@lists.postgresql.org; Mon, 13 Nov 2023 08:20:13 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r2SAu-006BXp-T3 for pgsql-hackers@postgresql.org; Mon, 13 Nov 2023 08:20:12 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4083f613272so35903865e9.1 for ; Mon, 13 Nov 2023 00:20:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; t=1699863603; x=1700468403; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=KcpflyYnx4yZ23/9TPKpjxpFJFHSil5t5Q6Ur3beF0Q=; b=RDNBJGu342cmGxmv9xd7sMvGN1wk9zL9x5+gsKW84eT2pD3rRmCdWGtqn9cCLNSSWw Eip5qQ0Kp8RCKwiUa1lnKPny359yiTCQte7IR+y/Tz6FfvxNfyQOYXt+TUVFiwcaGKI5 9yOE5ge7dLDAbL/peAW4YE+FwenwrwkaquIws= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699863603; x=1700468403; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KcpflyYnx4yZ23/9TPKpjxpFJFHSil5t5Q6Ur3beF0Q=; b=LiKxKdi0Ci+U7f0HonMzm2TKLBB8Oa1JFvNABFIxKsffozaS0iahYLL2s63v8Amwo0 HDvfl0TF4yJyKStUkbhI7CE6ROMcBzhluxDiqJb2UyPncGurLWV2tyMwYK+fRZvC1+8B tzJj8j6ZoUHou8m4iXKBW3HqO41yhsRJXwts6es2y7rkJ5WHLVJ4krGtRaooahSzfu6C l1gtWInVLrb7wFKqz3tjMipAfommhKIdzbjLiBxdBLnxrYat+6SK6wnWb09zcJxwgcIC oHnr5demQHaSy/6ArUoQqX05gKOkjI37ola/YJf2lcB/jLIASRBL8Vdl4r5E5pQNZWFN h/vg== X-Gm-Message-State: AOJu0YwQ+2Hq8JrjdeCf0Xygzg/PN7w6JtRyuu9nwKHm0fKGnMDsstgb pDOTYzGx56MmAvZp0hXaL3ic3CZ9Xg5mDQ08cHT0oQ== X-Google-Smtp-Source: AGHT+IGjS0jtM4p/EsXdJxgkUEOuDvUgAIM0aR25qJtpTItIQg4SlE7w+eADlt1cwV37OXX/CjXm0PAj3f/kgRggI54= X-Received: by 2002:a5d:5741:0:b0:32f:7db1:22f0 with SMTP id q1-20020a5d5741000000b0032f7db122f0mr3699053wrw.20.1699863603222; Mon, 13 Nov 2023 00:20:03 -0800 (PST) MIME-Version: 1.0 References: <202311081620.s2a7ao5jtlpe@alvherre.pgsql> In-Reply-To: From: Anthonin Bonnefoy Date: Mon, 13 Nov 2023 09:19:52 +0100 Message-ID: Subject: Re: Add PQsendSyncMessage() to libpq To: Anton Kirilov Cc: Alvaro Herrera , Jelte Fennema-Nio , Michael Paquier , Robert Haas , pgsql-hackers@postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, I've played a bit with the patch on my side. One thing that would be great would be to make this available in pgbench through a \syncpipeline meta command. That would make it easier for users to test whether there's a positive impact with their queries or not. I've wrote a patch to add it to pgbench (don't want to mess with the thread's attachment so here's a GH link https://github.com/bonnefoa/postgres/commit/047b5b05169e36361fe29fef9f430da= 045ef012d). Here's some quick results: echo "\set aid1 random(1, 100000 * :scale) \set aid2 random(1, 100000 * :scale) \startpipeline select 1; select * from pgbench_accounts where aid=3D:aid1; select 2; \syncpipeline select 1; select * from pgbench_accounts where aid=3D:aid2; select 2; \endpipeline" > /tmp/pipeline_without_flush.sql pgbench -T30 -Mextended -f /tmp/pipeline_without_flush.sql -h127.0.0.1 latency average =3D 0.383 ms initial connection time =3D 2.810 ms tps =3D 2607.587877 (without initial connection time) echo "\set aid1 random(1, 100000 * :scale) \set aid2 random(1, 100000 * :scale) \startpipeline select 1; select * from pgbench_accounts where aid=3D:aid1; select 2; \endpipeline \startpipeline select 1; select * from pgbench_accounts where aid=3D:aid2; select 2; \endpipeline" > /tmp/pipeline_with_flush.sql pgbench -T30 -Mextended -f /tmp/pipeline_with_flush.sql -h127.0.0.1 latency average =3D 0.437 ms initial connection time =3D 2.602 ms tps =3D 2290.527462 (without initial connection time) I took some perfs and the main change is from the server spending less time= in ReadCommand which makes sense since the commands are sent in a single tcp frame with the \syncpipeline version. Regards, Anthonin On Sun, Nov 12, 2023 at 2:37=E2=80=AFPM Anton Kirilov wrote: > > Hello, > > Thanks for the feedback! > > On 07/11/2023 09:23, Jelte Fennema-Nio wrote: > > But I think it's looking at the situation from the wrong direction. > [...] we should look at it as an addition to our current list of PQsend > functions for a new packet type. And none of those PQsend functions ever > needed a flag. Which makes sense, because they are the lowest level > building blocks that make sense from a user perspective: They send a > message type over the socket and don't do anything else. > > Yes, I think that this is quite close to my thinking when I created the > original version of the patch. Also, the protocol specification states > that the Sync message lacks parameters. > > Since there haven't been any comments from the other people who have > chimed in on this e-mail thread, I will assume that there is consensus > (we are doing a U-turn with the implementation approach after all), so > here is the updated version of the patch. > > Best wishes, > Anton Kirilov