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 1n9gHL-0006N6-Qc for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Jan 2022 04:39:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n9gHJ-0003x5-Gf for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Jan 2022 04:39:29 +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 1n9gHJ-0003ww-3w for pgsql-hackers@lists.postgresql.org; Tue, 18 Jan 2022 04:39:29 +0000 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n9gHD-0002Ch-Qr for pgsql-hackers@lists.postgresql.org; Tue, 18 Jan 2022 04:39:28 +0000 Received: by mail-io1-xd32.google.com with SMTP id v1so23984455ioj.10 for ; Mon, 17 Jan 2022 20:39:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=T8tTJJuPmlUqD6tGXZiL3bzNUlpJICkdc1tIBgJ9Epc=; b=6nwhsJF7q77PUzdES8wh6agbBKwkJX4dNBeUa37M/GrAVq96OmUdvUgtlY+TdQWDaE u+xLxYz8cOl4MrxA3SVAmxAwanQ5dl1XIDnWH2YP1Ap0BiEMrU/GioJj80NX4qNLDkQ7 djE8IYNvuIYgoG6tnuH5pyL/niAfwUu+l2zefwf10ASy1/7yh3mHK/BdhOQGSfsQ3itr OmAMplBjoFfTRw2kJc0Coae1jx03jYkH7s3G2+asdc8b18FPDnu06mHaUJXGylg1EXyj oliHwG6eFBK6wjByXBZ5Mb/pSMaeQPPENukCAPqVegSFkvwMNLm/SFxv2dVP5dQV15bU y5cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=T8tTJJuPmlUqD6tGXZiL3bzNUlpJICkdc1tIBgJ9Epc=; b=Y5ChXt53b/Q/1dyGrBFfvGviH2NAOy56oRa07EX4TK9rypNy/fHwN4w3JHrr+Tykea CraoW6GKcsTz2QYK6Gqs6wOJa+YX+KyexitcYIYfriEMbcHDR3KhePQwZNwg6M79cJSG L1sy5ST35rMwvha1+54h+FesNcruZgixfovsyXDZ7k6Datv3Y2dayyeosIOZFufYycgE DCcdUMySKggf+T0hxP9ae0u0dm5BMCjOF7fzeJIAANjjBaUMj+oYVD+rAGE9nUTw8NJo pvfOwKXNT46B7/c8YmlyuUDJUqhi4N3uc8jn/0v60fCvBkw1/uDM43/ulekK8qMae0UN vy1Q== X-Gm-Message-State: AOAM530XQie5Rg8EpR66CI5WuIp76JK6GVoVA/7h8+vbWZkL6EDqMftT XxfJZ4qQLoNs0L+Ud4+8qwO1otWHk5VUSw== X-Google-Smtp-Source: ABdhPJz8852cXSW4YBjK+enXqbIxX8BgiS5m23COoc/jESjmQJgkISyKBHrNoQaCYtTb0/5JNqnLXA== X-Received: by 2002:a02:a10b:: with SMTP id f11mr10254847jag.314.1642480761811; Mon, 17 Jan 2022 20:39:21 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id h18sm10864105iol.1.2022.01.17.20.39.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jan 2022 20:39:21 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 1FA16800C62; Mon, 17 Jan 2022 22:39:20 -0600 (CST) Date: Mon, 17 Jan 2022 22:39:20 -0600 From: Justin Pryzby To: Daniil Zakhlystov Cc: pgsql-hackers@lists.postgresql.org, Andrey Borodin Subject: Re: libpq compression (part 2) Message-ID: <20220118043919.GA23027@telsasoft.com> References: <20220112141526.GF14051@telsasoft.com> <20220113235827.GM14051@telsasoft.com> <18CFC392-0391-4439-9F02-FC1CF02FFA24@yandex-team.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <18CFC392-0391-4439-9F02-FC1CF02FFA24@yandex-team.ru> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Jan 18, 2022 at 02:06:32AM +0500, Daniil Zakhlystov wrote: > > => Since March, errmsg doesn't need extra parenthesis around it (e3a87b4). > I’ve resolved the stuck tests and added zlib support for CI Windows builds to patch 0003-*. Thanks > for the suggestion, all tests seem to be OK now, except the macOS one. It won't schedule in Cirrus > CI for some reason, but I guess it happens because of my GitHub account limitation. I don't know about your github account, but it works for cfbot, which is now green. Thanks for implementing zlib for windows. Did you try this with default compressions set to lz4 and zstd ? The thread from 2019 is very long, and starts off with the guidance that compression had been implemented at the wrong layer. It looks like this hasn't changed since then. secure_read/write are passed as function pointers to the ZPQ interface, which then calls back to them to read and flush its compression buffers. As I understand, the suggestion was to leave the socket reads and writes alone. And then conditionally de/compress buffers after reading / before writing from the socket if compression was negotiated. It's currently done like this pq_recvbuf() => secure_read() - when compression is disabled pq_recvbuf() => ZPQ => secure_read() - when compression is enabled Dmitri sent a partial, POC patch which changes the de/compression to happen in secure_read/write, which is changed to call ZPQ: https://www.postgresql.org/message-id/CA+q6zcUPrssNaRS+FyoBsD-F2stK1Roa-4sAhFOfAjOWLziM4g@mail.gmail.com pq_recvbuf() => secure_read() => ZPQ The same thing is true of the frontend: function pointers to pqsecure_read/write are being passed to zpq_create, and then the ZPQ interface called instead of the original functions. Those are the functions which read using SSL, so they should also handle compression. That's where SSL is handled, and it seems like the right place to handle compression. Have you evaluated that way to do things ? Konstantin said he put ZPQ at that layer seems to 1) avoid code duplication between client/server; and, 2) to allow compression to happen before SSL, to allow both (if the admin decides it's okay). But I don't see why compression can't happen before sending to SSL, or after reading from it? -- Justin