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 1nOxV6-0007GE-6u for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Mar 2022 08:04:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nOxV4-0001nK-IY for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Mar 2022 08:04:50 +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 1nOxV4-0001nB-8o for pgsql-hackers@lists.postgresql.org; Tue, 01 Mar 2022 08:04:50 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nOxV1-0005Au-TL for pgsql-hackers@lists.postgresql.org; Tue, 01 Mar 2022 08:04:49 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id BA1743201DA2; Tue, 1 Mar 2022 03:04:45 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 01 Mar 2022 03:04:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; bh=zQManiqxhVdk1/MvP3Mp0tKuqKajtZjGXhzNyU /Ql80=; b=RcRVGfXqHXj4W4aUEXVDWKmm038a/34dVLE4anL+AoBxmvqDpbC3Ud R+VaamMnZFtvrI877vrlSP5rlzDKaNUxqGfl/2DvRaIVXPSM32tNAJzvyR2Jfc/U tYVv7nAWDhWOgo7HHdW5Hc27GfrYUOEN6wb0BuZ7eyNlUdSTZyIyRosj33s6yV83 R1+9ubaSeyHbrcMLcgQT9+Eye01WMDB/SG9vQiEdFR+9RbAKx1brDi/WTJfxzMcs k+uJF0AIEiZXIfA7pShW4/CLCuTavZWXPD4knxwr07upktEQT+cBAqXvQu0VLWye qzIz3B0/jHY56CstUTHaaAKDXFA7f+oQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=zQManiqxhVdk1/MvP 3Mp0tKuqKajtZjGXhzNyU/Ql80=; b=RAx5nwgR7v/aE3U9MVhk3cCNmsFGbfGTj 92Ltrs8/vkatiLFueFJdHoIt6hmtw4A4E4TcUFmi2dqNrN52u48jSDUJwOMGHETY MGWjBokggpt0Ggui0hCAMEYs6fe0pUOqRbkKbFhyWEwQn0a119E2w706Da6dbZNk DaGQyGE9DX398nsQoGm9qc312woFTC0x3Yp458D5jzKHDoZuksrLjE5wXuaZ6tHy MJkcwChPQXqiHFx3cFWpGjRBR46It/73i/RRAv3pfA/vpGrG4g2EN6mLLRR1Iq0m HGfTwXBYD5jmWun3JSHZu1eczG5EPLYB6QVX2ZpqVKayCR4XxZsgw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddruddtuddgudduhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enfghrlhcuvffnffculdejtddmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepvdegudeuhfdtueeltedtveej heehieevueeigeelteegleejleeiueeiheegvefhnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Mar 2022 03:04:43 -0500 (EST) Date: Tue, 1 Mar 2022 17:04:35 +0900 From: Michael Paquier To: Georgios Cc: PostgreSQL Hackers , Rachel Heaton Subject: Re: Add LZ4 compression in pg_dump Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="aiqI1NAxYgfOrY/X" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --aiqI1NAxYgfOrY/X Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Feb 25, 2022 at 12:05:31PM +0000, Georgios wrote: > The first commit does the heavy lifting required for additional compression methods. > It expands testing coverage for the already supported gzip compression. Commit > bf9aa490db introduced cfp in compress_io.{c,h} with the intent of unifying > compression related code and allow for the introduction of additional archive > formats. However, pg_backup_archiver.c was not using that API. This commit > teaches pg_backup_archiver.c about cfp and is using it through out. Thanks for the patch. I have a few high-level comments. + # Do not use --no-sync to give test coverage for data sync. + compression_gzip_directory_format => { + test_key => 'compression', The tests for GZIP had better be split into their own commit, as that's a coverage improvement for the existing code. I was assuming that this was going to be much larger :) +/* Routines that support LZ4 compressed data I/O */ +#ifdef HAVE_LIBLZ4 +static void InitCompressorLZ4(CompressorState *cs); +static void ReadDataFromArchiveLZ4(ArchiveHandle *AH, ReadFunc readF); +static void WriteDataToArchiveLZ4(ArchiveHandle *AH, CompressorState *cs, + const char *data, size_t dLen); +static void EndCompressorLZ4(ArchiveHandle *AH, CompressorState *cs); +#endif Hmm. This is the same set of APIs as ZLIB and NONE to init, read, write and end, but for the LZ4 compressor (NONE has no init/end). Wouldn't it be better to refactor the existing pg_dump code to have a central structure holding all the function definitions in a common structure so as all those function signatures are set in stone in the shape of a catalog of callbacks, making the addition of more compression formats easier? I would imagine that we'd split the code of each compression method into their own file with their own context data. This would lead to a removal of compress_io.c, with its entry points ReadDataFromArchive(), WriteDataToArchive() & co replaced by pointers to each per-compression callback. > Furthermore, compression was chosen based on the value of the level passed > as an argument during the invocation of pg_dump or some hardcoded defaults. This > does not scale for more than one compression methods. Now the method used for > compression can be explicitly requested during command invocation, or set during > hardcoded defaults. Then it is stored in the relevant structs and passed in the > relevant functions, along side compression level which has lost it's special > meaning. The method for compression is not yet stored in the actual archive. > This is done in the next commit which does introduce a new method. That's one thing Robert was arguing about with pg_basebackup, so that would be consistent, and the option set is backward-compatible as far as I get it by reading the code. -- Michael --aiqI1NAxYgfOrY/X Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmId05MACgkQnvQgOdby QH1mBhAAo/AyyBbJi/8vu7sx0a72VlMePX3WdCMI6HyD8WByHFd3NlUhrIJeV69f BoReyY8/H9UiIVbn8ngHdpmGLdfZQrhV21Id9sap9/IGntjekUrM2G0STWVeHll/ 0H9nlVbC+3gHWA/LQstEd2tNTOIuvMVskWVmBkHKVP8fWL3BBUOQZp1nvQOsEblt 78LX4VZ6IK9lJUbrhTNQYOJ/JUQJMvpKsiFs8/p3Qxw/s8WhbolM7OSy6/XCHxpv y+lqhG+N0RLC2Va/iYbqeJzEew93bmLiltym5jd4wrYs7zs03Y9xSck11G+C5qL0 VcgtgZbHXKvYS33FRuCMxIsGq3mzudNKHzoo3qxRqcFie8BF1XVL+092kzIhdlRM BDJUKN7yHCFR4pZaSVwo1+wYqyrqPPWam8oV1p8J+sjG72bvmsVBzmnOirpkp485 wsTstEUg9HTJZVj+mJaO63x0XBF9Q2ESsaSFjiSsN1niX1slRhkxyS5EzMC/5Lx+ 0GNCoFnW6p8obyH8BxLAV7K/WehyDJn9b01+x+4gx+O9wEIC///1W3Y6GJCHkb3w 4ZN7/hQxY0Vg/JhJGZgldFnqYH5SUXmm+Rs+jPmrQs4PlWzc/zugzOeTSDd2PH51 /KQlQDHabDQV9K46De+UHWC4me4YppnZPIjBS3jUcvvfilaCwl4= =3qt7 -----END PGP SIGNATURE----- --aiqI1NAxYgfOrY/X--