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 1neVVE-0005Hx-ST for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Apr 2022 05:25:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1neVVD-00050P-9t for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Apr 2022 05:25:15 +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 1neVVB-0004yh-Sl for pgsql-hackers@lists.postgresql.org; Wed, 13 Apr 2022 05:25:15 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1neVV8-0004QT-6H for pgsql-hackers@lists.postgresql.org; Wed, 13 Apr 2022 05:25:12 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id F00F65C0251; Wed, 13 Apr 2022 01:25:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 13 Apr 2022 01:25:08 -0400 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; t=1649827508; x=1649913908; bh=4r1TTrnUpB yI6qFGmFoNxKAv9C1nbn8hDuy6z8ej9bM=; b=mbs27SPjNfUN20fX8UisG+dEjE cG8ZMg4MSRoG/VygmHjvcJpUlvItyWkyuXEsdRivIh+h87KfH9M9BXdZjNly4TmN f34g4FsjJmfrK7xW4PW8jByNMYG/cDn2jVlQxNB1irAYx7Vvtn9JKUJszuPfhaIc Y0LcrC88GjTwh2iJbZ3OGsxgpG+XE7lo9GwARJaACuGiPEVCY+zujK6C45Tcr77N lg8cCJF+GlDcOzQ3q55P1VWv9HnGf1NpApt6UNxWs3qdA41S2lhlS94FAyiRqvjJ fLUBNUoy0H3f96Nd0EdDUXutu1PWALmPNNWSNMYir5BxV3c8NFOD7tFan8XA== 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=fm1; t=1649827508; x= 1649913908; bh=4r1TTrnUpByI6qFGmFoNxKAv9C1nbn8hDuy6z8ej9bM=; b=b x5WKHjkY7ZytcxOE6HWpcSpPu6dkTqRXatGhms5J4Awx89TEbb8BriupcElgqYwV a8Eg04p9e+QyH/gNPb2QG3mlvAa46cWd7EiRLCa+6BaRrBL7HxYvsu8NJRqLCAzd EqU2YGu0cNTXydlpZrpizDLNeLW5meC1S9ucEF86Iz7R8gbDdm598FXb7lsTa/s3 Ic9XwQ+Y1vQZcObRGXFgmRMm9mzPh5h/X/XCTWBfBvWR0knfx6MVILPWi5v/mmT0 EDoByG3q2LnJAx1TjfmkD19408+MONl6NM/MMkzrxtE1pVCkTMtk63zglP5qBxrd Cy7X8pUh3nU26UfeYtUcA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudekledgleehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdlfeehmdenucfjughrpeffhffvuffkfhggtggujgesghdtroertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeehgedtueehkeetgeeuvedtleel keeggeefteefjeejgfekheeikeevjeehudejheenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Apr 2022 01:25:07 -0400 (EDT) Date: Wed, 13 Apr 2022 14:25:02 +0900 From: Michael Paquier To: gkokolatos@pm.me Cc: Postgres hackers , Robert Haas Subject: Re: Fixes for compression options of pg_receivewal and refactoring of backup_compression.{c,h} Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="tPP7hahSjzZLCtxv" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --tPP7hahSjzZLCtxv Content-Type: multipart/mixed; boundary="RL5IJ4sIEOiDNQDR" Content-Disposition: inline --RL5IJ4sIEOiDNQDR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 12, 2022 at 06:22:48PM +0900, Michael Paquier wrote: > On Mon, Apr 11, 2022 at 12:46:02PM +0000, gkokolatos@pm.me wrote: >> It looks good. If you choose to discard the comment regarding the use of >> 'method' over 'algorithm' from above, can you please use the full word i= n the >> variable, e.g. 'wal_compress_algorithm' instead of 'wal_compress_algo'. = I can >> not really explain it, the later reads a bit rude. Then again that may b= e just >> me. >=20 > Thanks. I have been able to do an extra pass on 0001 and 0002, fixing > those naming inconsistencies with "algo" vs "algorithm" that you and > Robert have reported, and applied them. For 0003, I'll look at it > later. Attached is a rebase with improvements about the variable > names. This has been done with the proper renames. With that in place, I see no reason now to not be able to set the compression level as it is possible to pass it down with the options available. This requires only a couple of lines, as of the attached. LZ4 has a dummy structure called LZ4F_INIT_PREFERENCES to initialize LZ4F_preferences_t, that holds the compression level before passing it down to LZ4F_compressBegin(), but that's available only in v1.8.3. Using it risks lowering down the minimal version of LZ4 we are able to use now, but replacing that with a set of memset()s is also a way to set up things as per its documentation. Thoughts? -- Michael --RL5IJ4sIEOiDNQDR Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="receivewal-level.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/bin/pg_basebackup/walmethods.c b/src/bin/pg_basebackup/wal= methods.c index d5bcc208a9..1b3cc5c4f7 100644 --- a/src/bin/pg_basebackup/walmethods.c +++ b/src/bin/pg_basebackup/walmethods.c @@ -165,6 +165,7 @@ dir_open_for_write(const char *pathname, const char *te= mp_suffix, size_t pad_to_ { size_t ctx_out; size_t header_size; + LZ4F_preferences_t prefs; =20 ctx_out =3D LZ4F_createCompressionContext(&ctx, LZ4F_VERSION); if (LZ4F_isError(ctx_out)) @@ -177,8 +178,13 @@ dir_open_for_write(const char *pathname, const char *t= emp_suffix, size_t pad_to_ lz4bufsize =3D LZ4F_compressBound(LZ4_IN_SIZE, NULL); lz4buf =3D pg_malloc0(lz4bufsize); =20 + /* assign the compression level, default is 0 */ + memset(&prefs, 0, sizeof(prefs)); + memset(&prefs.frameInfo, 0, sizeof(prefs.frameInfo)); + prefs.compressionLevel =3D dir_data->compression_level; + /* add the header */ - header_size =3D LZ4F_compressBegin(ctx, lz4buf, lz4bufsize, NULL); + header_size =3D LZ4F_compressBegin(ctx, lz4buf, lz4bufsize, &prefs); if (LZ4F_isError(header_size)) { dir_data->lasterrstring =3D LZ4F_getErrorName(header_size); --RL5IJ4sIEOiDNQDR-- --tPP7hahSjzZLCtxv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmJWXq4ACgkQnvQgOdby QH0ELw//f7Nli4Fx1U4L6lDdlhCVEPlGNn61ILJNKAx/5saPJ+tG+WX7ESo8tKvv apLypuUTrt1i6lzktp5pOmoGWqkApphNBq7ROEpI+c5kCfTZD25tVvsPqImKE4UH of9DVF3Q3CpOPswiIak02wVGEaZmzdKRciGugjeofg3yRL9Ja6jfAl7PK+/sr6uT fw+Z3Xr7agBWCfG50IN2W3Drn56Yb85J+YmfD0McWVxg/Ndxx/TbQGchRD4XgaA0 N03JP5aED5VOb4AiiUoDQKAzcfLSkKxOaN3NjDngyeove6R/mOejs4pIHl+rq+ih 6z+zbiuSnuqwEXQJS6KqDLjU3vhPuZTmINKQgJo2tJkf1WBhIisRW4i2MV5+AhL5 DFl90/UtMRCWsTYlKNFhTP/4NiLh8l+d9depQBzzjCB+k/LsGkbmHDPgSNDil5+R HumYbKCCZ6JDwvoFZ8Fy3J4WqC1d/3wwHUWhXnh/MZrPATOTN9f9WZdtpOvQWkUS UY4M3pbBUsx5xXgKwtmRLie1zHl20WJfsbR+LRvYskaUKqm92QwQFvSUNplCU7/M 1Aq7lDoIDQNpjGVQf94oHYP7p1Poir+yVRggxR0NkB1UGsa1BOuimQ3DzDCxpHB2 Vynnc25nEfFZolEBufLLuIQ0aFDSe8+kS+8ZXYzwqqUUkFOihOo= =DBIq -----END PGP SIGNATURE----- --tPP7hahSjzZLCtxv--