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 1pIX6N-0006qU-M9 for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Jan 2023 15:45:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pIX6M-0000cH-2V for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Jan 2023 15:45:18 +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 1pIX6L-0000Yz-NM for pgsql-hackers@lists.postgresql.org; Thu, 19 Jan 2023 15:45:17 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pIX6I-0006DM-6p for pgsql-hackers@lists.postgresql.org; Thu, 19 Jan 2023 15:45:16 +0000 Received: by mail-wm1-x332.google.com with SMTP id d4-20020a05600c3ac400b003db1de2aef0so1570606wms.2 for ; Thu, 19 Jan 2023 07:45:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=oblhFr3dRm8arI+fgi98obtF3eo0h8C3yVcAHE9Uy/c=; b=c2QNPHYqY4BPuyu6p4hg8cPdWbmPJMu5/yUC+HKN6PfdS26XwyAzy1LhWkpk4uwxLX uu78RHAIK9dAnBRkp00xWlV8UauzxOndz1f8LrQ0aPy5MsqKn+3Gf9/azpj9mIQbU5/H veD7eWlQlyGv/zvA1i8oCQILLMbdqcltLvQPosqwWD2mOe3NJL/lVd/OeHJEWA2bDzO+ ifhNle/TjvlN9KlADnnVVMKna/i+wlQF2eB9OF5qwO2+B+PX43Lu3/s6Ce73xtdgsV9W HeD5FRN4ON5prG7gSTsfL/YBimK6NGP9pPGkcwFhpAjnclJJuvEfZAhr/cF6Gi8tMAwe t1kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oblhFr3dRm8arI+fgi98obtF3eo0h8C3yVcAHE9Uy/c=; b=YA9YpxWC1vD8NpyCmcwkfHG04XV92ZKOH43iQys2MdYaSgzU61dK7KWfrJV8Kvb0Pu qnBXAb3TTULpmmJRuWRNqT7K35FGcT89i8Qwj82KAjTcupR7Pumy6YIcYqlIV8c9iA5f Vy/pCoaoPQjozpUQAmjGGHimILSsTIH+cmpkqITWjv343Q4GdJZKZQn10JNGN1kBe574 Vo0WIJVACV9CupFq0kN2SavVdXcYpc4JguneQlKTVjI/GuXomMAVN9dHOh4rkv3Sfk1D g2NpRqY/XRG7ngovFITwKPC2UMfHoXCNAuZoPD/NtUO4sGORzb+b8WYUZb3y4f5KkoC/ U2dA== X-Gm-Message-State: AFqh2kpyGG61Sznjm2TE6hqPE4IMg5CB3DAd5hAX4zixsx7+qOMREX8q ntlvfR53irR2HXFy+liIaZ9rF53p1sTYaJKtg3KhKy+s07XQF6plsTry5Al1RRbnEnTPRUXGLQY O6jy4hnVamQPmiVRLi51MyYgUNVi1OZ8cPlBeFdgkapNc0idQ659/mN+0OnszmSO0khin7sCOvW MR9OmIBuPucKKPr3FJJ+Yc91Q0Lm9Cg0yv3JjqIdfxenrBSVpUhgx72ETIObGXH+A29A09dAWQi 4/75x/wV9oJhTah/v647SX1yVF6kTgTLWT/QoFRwF4CAHJi9mvpM1odH9gn X-Google-Smtp-Source: AMrXdXuPsBZnNLpbjlXHZcMgcwiJ9GKFTLi62b9dYzSk/Z2U1PqGGaQmFJdub890YowO19JTPcoo9g== X-Received: by 2002:a05:600c:a29f:b0:3d9:f42c:56c5 with SMTP id hu31-20020a05600ca29f00b003d9f42c56c5mr10895438wmb.4.1674143112917; Thu, 19 Jan 2023 07:45:12 -0800 (PST) Received: from [10.137.0.17] (ip-86-49-228-162.bb.vodafone.cz. [86.49.228.162]) by smtp.gmail.com with ESMTPSA id b13-20020a05600003cd00b002be07cbefb2sm12418807wrg.18.2023.01.19.07.45.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Jan 2023 07:45:12 -0800 (PST) Message-ID: <6ab89d42-0345-b96e-02d4-68e171cdbe03@enterprisedb.com> Date: Thu, 19 Jan 2023 16:45:10 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: Add LZ4 compression in pg_dump Content-Language: en-US To: gkokolatos@pm.me Cc: Michael Paquier , Justin Pryzby , pgsql-hackers@lists.postgresql.org, Rachel Heaton References: <20221222170859.GO1153@telsasoft.com> <20230108194524.GA27637@telsasoft.com> <20230114214308.GC9837@telsasoft.com> <20230116015625.GH9837@telsasoft.com> <41036470-041b-08a3-469d-fe07de2bc58e@enterprisedb.com> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/18/23 20:05, gkokolatos@pm.me wrote: > > > > > > ------- Original Message ------- > On Wednesday, January 18th, 2023 at 3:00 PM, Tomas Vondra wrote: > > >> >> >> Hi, >> >> On 1/16/23 16:14, gkokolatos@pm.me wrote: >> >>> Hi, >>> >>> I admit I am completely at lost as to what is expected from me anymore. >> > >> >> Unfortunately, this plays against this patch - I'm certainly in favor of >> adding lz4 (and other compression algos) into pg_dump, but if I commit >> 0001 we get little benefit, and the other parts actually adding lz4/zstd >> are treated as "WIP / for completeness" so it's unclear when we'd get to >> commit them. > > Thank you for your kindness and for taking the time to explain. > >> So if I could recommend one thing, it'd be to get at least one of those >> WIP patches into a shape that's likely committable right after 0001. > > This was clearly my fault. I misunderstood a suggestion upthread to focus > on the first patch of the series and ignore documentation and comments on > the rest. > > Please find v21 to contain 0002 and 0003 in a state which I no longer consider > as WIP but worthy of proper consideration. Some guidance on where is best to add > documentation in 0002 for the function pointers in CompressFileHandle will > be welcomed. > This is internal-only API, not meant for use by regular users and/or extension authors, so I don't think we need sgml docs. I'd just add regular code-level documentation to compress_io.h. For inspiration see docs for "struct ReorderBuffer" in reorderbuffer.h, or "struct _archiveHandle" in pg_backup_archiver.h. Or what other kind of documentation you had in mind? >> >>> I had posted v19-0001 for a committer's consideration and v19-000{2,3} for completeness. >>> Please find a rebased v20 attached. >> >> >> I took a quick look at 0001, so a couple comments (sorry if some of this >> was already discussed in the thread): > > Much appreciated! > >> >> 1) I don't think a "refactoring" patch should reference particular >> compression algorithms (lz4/zstd), and in particular I don't think we >> should have "not yet implemented" messages. We only have a couple other >> places doing that, when we didn't have a better choice. But here we can >> simply reject the algorithm when parsing the options, we don't need to >> do that in a dozen other places. > > I have now removed lz4/zstd from where they were present with the exception > of pg_dump.c which is responsible for parsing. > I'm not sure I understand why leave the lz4/zstd in this place? >> 2) I wouldn't reorder the cases in WriteDataToArchive, i.e. I'd keep >> "none" at the end. It might make backpatches harder. > > Agreed. However a 'default' is needed in order to avoid compilation warnings. > Also note that 0002 completely does away with cases within WriteDataToArchive. > OK, although that's also a consequence of using a "switch" instead of plan "if" branches. Furthermore, I'm not sure we really need the pg_fatal() about invalid compression method in these default blocks. I mean, how could we even get to these places when the build does not support the algorithm? All of this (ReadDataFromArchive, WriteDataToArchive, EndCompressor, ...) happens looong after the compressor was initialized and the method checked, no? So maybe either this should simply do Assert(false) or use a different error message. >> 3) While building, I get bunch of warnings about missing cfdopen() >> prototype and pg_backup_archiver.c not knowing about cfdopen() and >> adding an implicit prototype (so I doubt it actually works). > > Fixed. cfdopen() got prematurely introduced in 5e73a6048 and then got removed > in 69fb29d1af. v20 failed to properly take 69fb29d1af in consideration. Note > that cfdopen is removed in 0002 which explains why cfbot didn't complain. > OK. >> 4) "cfp" struct no longer wraps gzFile, but the comment was not updated. >> FWIW I'm not sure switching to "void *" is an improvement, maybe it'd be >> better to have a "union" of correct types? > > Please find and updated comment and a union in place of the void *. Also > note that 0002 completely does away with cfp in favour of a new struct > CompressFileHandle. I maintained the void * there because it is used by > private methods of the compressors. 0003 contains such an example with > LZ4CompressorState. > I wonder if this (and also the previous item) makes sense to keep 0001 and 0002 or to combine them. The "intermediate" state is a bit annoying. >> 5) cfopen/cfdopen are missing comments. cfopen_internal has an updated >> comment, but that's a static function while cfopen/cfdopen are the >> actual API. > > Added comments to cfopen/cfdopen. > OK. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company