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 1psn6A-0000Ev-VH for pgsql-hackers@arkaria.postgresql.org; Sat, 29 Apr 2023 16:06:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1psn68-0002sy-L4 for pgsql-hackers@arkaria.postgresql.org; Sat, 29 Apr 2023 16:06:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1psn68-0002so-98 for pgsql-hackers@lists.postgresql.org; Sat, 29 Apr 2023 16:06:56 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1psn63-005nWC-Nz for pgsql-hackers@postgresql.org; Sat, 29 Apr 2023 16:06:55 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f18335a870so4837795e9.0 for ; Sat, 29 Apr 2023 09:06:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682784410; x=1685376410; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=FqCOR+5Eumc3B9Jin0YAZ+pNa/CCkhzzaluoLULOyDg=; b=Jka/vBijvk0bWWsOdNI8/6p2ZrK+ekyXv5VV1xek3kd1T3+YfBx1iMxYjdVg+vzDbN PAPlArsn4H2rZxSv92N/JneUaoS1DpuP3QWU+M5QrF91zgBKIdZsAGWSSAsnCPAcMfcv pgS7+UDeDevUu1VB3xCpdgq8e6u+cPkQvMAPS2r5RLtwY3wdWDI8v5PHoujnpgKptW5Y WZ4tKhZhKpdh5B6AUVA/hbx7UiC71hyo288dIyxcEsdfX8nbRq2t4At85+DmpfIAYb2x fOLwgZTv2yJBbxIyQwffMfqWqWaHu2ZNQJRabkrSgZhAMMo0TO2a8chgGo+WK/7krhJ1 K9wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682784410; x=1685376410; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FqCOR+5Eumc3B9Jin0YAZ+pNa/CCkhzzaluoLULOyDg=; b=klUu3n7Hll/X1X2XWEzPx7jUmRCC8gAyGc/CrpiU5vNDLTssP1kz+AfFRKLUC27sSH GlvGRyVFml1yUKut842+4cvmtEyzmRxhjSt/8y1U1/zVQcnBY4NRJA+1o4oBh//kNyP2 RVR20+VhKC2A4qlVUL5+oxjvcYujBZ1IO7x3JESPCofJKtdvTViFwCLc56jW0/+3yHST l/7LW3ByELIaw03VWg9wzebqp9fvdo2kbawx5CnBM4pHs02pyo5iACRNyoy53VoKoi9N dp6jdmnZ5kp24X0blxHYvOThFf3AfNp5NJwml0ZxiDcC+cjfFizZnzpFtB36ahSAV5vG yOtg== X-Gm-Message-State: AC+VfDztJomI8DczSafDE9TvwdUNQoSkOLEmrr97cjDF+lRXK/e20quK Jc6x3J3mm1K3r+ARTVoXDIM= X-Google-Smtp-Source: ACHHUZ5q42f0XVWt5jzkmZJGcbHEIhMfnpKL9N/AH4WmkOCRrKQBeVR0ja6pvYIPzQ0i+pHhLgbDBg== X-Received: by 2002:a1c:7317:0:b0:3f1:812d:1da3 with SMTP id d23-20020a1c7317000000b003f1812d1da3mr6661958wmb.0.1682784409701; Sat, 29 Apr 2023 09:06:49 -0700 (PDT) Received: from [10.0.0.2] (cpc92320-cmbg19-2-0-cust797.5-4.cable.virginm.net. [82.13.67.30]) by smtp.gmail.com with ESMTPSA id ip29-20020a05600ca69d00b003f1712b1402sm30927339wmb.30.2023.04.29.09.06.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 29 Apr 2023 09:06:49 -0700 (PDT) Message-ID: Date: Sat, 29 Apr 2023 17:06:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 From: Anton Kirilov Subject: Re: Add PQsendSyncMessage() to libpq To: Robert Haas Cc: pgsql-hackers@postgresql.org References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, On 28/04/2023 13:06, Robert Haas wrote: > On Fri, Mar 24, 2023 at 6:39 PM Anton Kirilov wrote: >> I have attached a patch that introduces PQsendSyncMessage()... > > I wonder whether this is the naming that we want. The two names are > significantly different. Something like PQpipelineSendSync() would be > more similar. The reason is that the function is modeled after PQsendFlushRequest(), since it felt closer to what I was trying to achieve, i.e. appending a protocol message to the output buffer without doing any actual I/O operations. > I also wonder, really even more, whether it would be better to do > something like PQpipelinePutSync(PGconn *conn, bool flush) with > PQpipelineSync(conn) just meaning PQpipelinePutSync(conn, true). Actually I believe that there is another issue with PQpipelineSync() that has to do with ergonomics - according to a comment inside its body ( https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/interfaces/libpq/fe-exec.c;h=a16bbf32ef5c0043eee9c92ab82bf4f11386ee47;hb=HEAD#l3189 ) it could fail silently to send all the buffered data, which seems to be problematic when operating in non-blocking mode. In practice, this means that all calls to PQpipelineSync() must be followed by execution of PQflush() to check whether the application should poll for write readiness. I suppose that that was the reason why I was going for a solution that did not combine changing the connection state with doing I/O operations. In any case I am not particularly attached to any naming or the exact shape of the new API, as long as it achieves the same goal (reducing the number of system calls), but before I make any substantial changes to my patch, I would like to hear your thoughts on the matter. Best wishes, Anton Kirilov