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 1pbq0q-00018l-PK for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Mar 2023 21:47:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pbq0p-0001jw-Lr for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Mar 2023 21:47:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pbq0p-0001jl-7m for pgsql-hackers@lists.postgresql.org; Mon, 13 Mar 2023 21:47:23 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pbq0i-0000w6-I7 for pgsql-hackers@lists.postgresql.org; Mon, 13 Mar 2023 21:47:22 +0000 Received: by mail-ed1-x535.google.com with SMTP id r15so27235503edq.11 for ; Mon, 13 Mar 2023 14:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1678744035; 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=VWaLBzHd/IuCXS5FvHrREM+gDib4/SeEnJn/+ahHVaI=; b=GzW9aNoZP3AIhNbBcfnmuFqq1oSR4Z82lWY5nYPs0HQ1eKc3bZMnOnfLpeYLBl0dLY 528p+zOQKgRWEn5IUi40YNH5Q1rpXQYgY7XNa7jzuRAvXS89pOLSux/MhfsqZ+HHZgKe DaIu0EjM7oERjyoGlL8pbHTLyeCRNgZDdMc+RbLvtLVrqsodR0Zq3N0t/chSqpnljFrv r1uW/Q5N8V6NXwicQgf2mgRFkpsoc08Hhd6D4aKnOR1VRW4Bi/zXGfhy9LiYX6Kt1CxP PzsEXdGM3DwFuO5/egwr9jf7cKolZqePZbalD9fDsdf6iqs+4mqCP2I9MDmrjG3ADpfO bMtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678744035; 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=VWaLBzHd/IuCXS5FvHrREM+gDib4/SeEnJn/+ahHVaI=; b=AkV7Fu69uyGizRAm2klPNluZ3yYL2gA6ElE7c3F2TxNo5Oc0OkhdKPebQ1Eg1VoH/4 WfMLHT4jYD0/f4c78yHhSKr3X8uq0L9ViBnj0h4KnlEy6mbg6YsZmyOFFbTVPJVh8WHg v5z31iPE0rGVe8h38260GHg1n1rRXT34cGJd6kNJylsIWuNrkGEuT63+IEq1RAGUg8EA Ol3RtfdWkwfzqcQG9lf6SUfHXYS35EcSMS0q4OofoOKPayIfYWqcOiK6rQb0GL0sOkMj M3ixR4jqWsU9gEFSJTer9XoW+OaNiepAdA8pSTIrEWxwcb3TD41dsXlAgScrwlbyKHSX W2aQ== X-Gm-Message-State: AO0yUKVzjkgfqlZ3BW6eqIvHzn1jbXI7Fd5zbQglhfl0h8idf2aai7uK E7KUO9mQhoYQG/xuMuMht/SjItBJrNu5yR/rbb0M6AyoA32ULhEB4CvIVhsGBwvahdSJTS3rL1I HLchxzx7lpFXNDs2iZYmD92Vd6vVvB3Ju4iycjlAGXrFDpF14xAbuNK/z/si9O303qMWN0SnYnA HorJf1JJS7QGavgkkrkvW/aJz7aqb5xkeJSp4JtFlBirAGWxlMoLSh X-Google-Smtp-Source: AK7set/7MJ7tkurfTpZORV3QdKoPdUamNDJqidLZF3sKUAH2r+lYIJAwhe0IugYYqkvFI4OOC7J8HQ== X-Received: by 2002:aa7:c1d7:0:b0:4ab:d1f4:4b88 with SMTP id d23-20020aa7c1d7000000b004abd1f44b88mr28386038edp.41.1678744034721; Mon, 13 Mar 2023 14:47:14 -0700 (PDT) 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 c11-20020a50d64b000000b004fa19f5ba99sm242941edj.79.2023.03.13.14.47.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Mar 2023 14:47:14 -0700 (PDT) Message-ID: Date: Mon, 13 Mar 2023 22:47:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: Add LZ4 compression in pg_dump Content-Language: en-US To: Justin Pryzby Cc: gkokolatos@pm.me, shiy.fnst@fujitsu.com, Michael Paquier , pgsql-hackers@lists.postgresql.org, Rachel Heaton References: <535565cd-b69f-c064-a845-15c0fc44db4a@enterprisedb.com> <22cb80ed-ec87-54c7-fd5b-cdcf79766bb1@enterprisedb.com> <8421f53d-c9f7-c02e-3278-9f9522a8e8f3@enterprisedb.com> <20230228235834.GC30529@telsasoft.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 Hi Justin, Thanks for the patch. On 3/8/23 02:45, Justin Pryzby wrote: > On Wed, Mar 01, 2023 at 04:52:49PM +0100, Tomas Vondra wrote: >> Thanks. That seems correct to me, but I find it somewhat confusing, >> because we now have >> >> DeflateCompressorInit vs. InitCompressorGzip >> >> DeflateCompressorEnd vs. EndCompressorGzip >> >> DeflateCompressorData - The name doesn't really say what it does (would >> be better to have a verb in there, I think). >> >> I wonder if we can make this somehow clearer? > > To move things along, I updated Georgios' patch: > > Rename DeflateCompressorData() to DeflateCompressorCommon(); Hmmm, I don't find "common" any clearer than "data" :-( There needs to at least be a comment explaining what "common" does. > Rearrange functions to their original order allowing a cleaner diff to the prior code; OK. I wasn't very enthusiastic about this initially, but after thinking about it a bit I think it's meaningful to make diffs clearer. But I don't see much difference with/without the patch. The git diff --diff-algorithm=minimal -w e9960732a~:src/bin/pg_dump/compress_io.c src/bin/pg_dump/compress_gzip.c Produces ~25k diff with/without the patch. What am I doing wrong? > Change pg_fatal() to an assertion+comment; Yeah, that's reasonable. I'd even ditch the assert/comment, TBH. We could add such protections against "impossible" stuff to a zillion other places and the confusion likely outweighs the benefits. > Update the commit message and fix a few typos; > Thanks. I don't want to annoy you too much, but could you split the patch into the "empty-data" fix and all the other changes (rearranging functions etc.)? I'd rather not mix those in the same commit. >> Also, InitCompressorGzip says this: >> >> /* >> * If the caller has defined a write function, prepare the necessary >> * state. Avoid initializing during the first write call, because End >> * may be called without ever writing any data. >> */ >> if (cs->writeF) >> DeflateCompressorInit(cs); >> >> Does it actually make sense to not have writeF defined in some cases? > > InitCompressor is being called for either reading or writing, either of > which could be null: > > src/bin/pg_dump/pg_backup_custom.c: ctx->cs = AllocateCompressor(AH->compression_spec, > src/bin/pg_dump/pg_backup_custom.c- NULL, > src/bin/pg_dump/pg_backup_custom.c- _CustomWriteFunc); > -- > src/bin/pg_dump/pg_backup_custom.c: cs = AllocateCompressor(AH->compression_spec, > src/bin/pg_dump/pg_backup_custom.c- _CustomReadFunc, NULL); > > It's confusing that the comment says "Avoid initializing...". What it > really means is "Initialize eagerly...". But that makes more sense in > the context of the commit message for this bugfix than in a comment. So > I changed that too. > > + /* If deflation was initialized, finalize it */ > + if (cs->private_data) > + DeflateCompressorEnd(AH, cs); > > Maybe it'd be more clear if this used "if (cs->writeF)", like in the > init function ? > Yeah, if the two checks are equivalent, it'd be better to stick to the same check everywhere. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company