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 1nQ6M4-0000q8-2p for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Mar 2022 11:44:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nQ6M1-0003Tb-NY for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Mar 2022 11:44:13 +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 1nQ6M1-0003TQ-Dz for pgsql-hackers@lists.postgresql.org; Fri, 04 Mar 2022 11:44:13 +0000 Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nQ6Ly-0008Da-1l for pgsql-hackers@postgresql.org; Fri, 04 Mar 2022 11:44:12 +0000 Received: by mail-io1-xd2c.google.com with SMTP id w7so9251207ioj.5 for ; Fri, 04 Mar 2022 03:44:09 -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=FbAAO8BHFKbdVXjdERokLhZ3COGZrkCfrrPuwKYthUY=; b=r8MfMB/bcy7TtU3Qno6XhcznUNTn4w5MH6wOrUf5RYPO51BZ2jk5tXgj9X4FdalBrG YfHfgRBrH8eCUzakogDc+TIk1VyFhwwpP6uTb34QRPtDi9Y8WSCthw3La3V1EtjmA7rC XvXEzQ3xA9xYbPYV9DUpJdolEp2O0YHRMCDragTuPzvtQrlmomiziAp44U9ragtqHfxE 4aL8OFQxQcRUdC17x4z5Ngi4TMCR8tZU6D5J9KcpUvuzJ6PcKq2SQEDfkQL7sAeouJJr v73sPnbgpcfztiMBA6RvpbPtv4f6ruiIX5mHO5VBajLdpAQwhjeDT5KcCZVx+d4W1zl6 f+9A== 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=FbAAO8BHFKbdVXjdERokLhZ3COGZrkCfrrPuwKYthUY=; b=SWQwHVccxUvDDM5/0WLihAxqvzVjK2SkRTqr2Is9G+Ki8ews3AsryPnIXFnFIo3Lzo wR7nSJ1u9TfPD3TMgZguPJV72fVPdROkPdcTT0maBVoQuQ1QIPE5T1DLtrzv4ScRr7Ps fU5dBbu1qNS8qtnQ08rIpQ6qlash9h/U1DH1c9SjgSiQeaupL/GT0rQ2dXIB5NRkoQG+ bXrLhYQcX4PCIN3IViDFpVUuGuDamh1Ka7TnXm8WCpTp6C6twbcVip5/MCKfxOrdz26i VHhnJKWijHbnUuE11nzLm0ReVsXwDKY07ImCyeIvht02HFleseb9ywKaX3j9ByAsmWhz r8gg== X-Gm-Message-State: AOAM530N6IcbxX3QTyFA+zmWoeWngcYHlVr7AUGLZjYDO58ZiI29LEmg kxldR54/2NEHA+RGI/1MQg4smA== X-Google-Smtp-Source: ABdhPJx321lkCTDGQeaQFy1uowhcaz627flqq3Lb+vl/7HUTF5dl25CPHZAmRfPK3F8+H4C2WgY5HA== X-Received: by 2002:a05:6638:1248:b0:314:bdef:3b66 with SMTP id o8-20020a056638124800b00314bdef3b66mr32462035jas.97.1646394247940; Fri, 04 Mar 2022 03:44:07 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id f13-20020a056e02168d00b002c4b8023f1dsm5284915ila.43.2022.03.04.03.44.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Mar 2022 03:44:07 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 2CAF3801860; Fri, 4 Mar 2022 05:44:06 -0600 (CST) Date: Fri, 4 Mar 2022 05:44:06 -0600 From: Justin Pryzby To: Michael Paquier Cc: Andrey Borodin , Peter Eisentraut , Heikki Linnakangas , pgsql-hackers@postgresql.org, Thomas Munro , Peter Geoghegan , Andres Freund , Robert Haas Subject: Re: wal_compression=zstd Message-ID: <20220304114405.GK27651@telsasoft.com> References: <20220222231948.GJ9008@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 Fri, Mar 04, 2022 at 04:19:32PM +0900, Michael Paquier wrote: > On Tue, Feb 22, 2022 at 05:19:48PM -0600, Justin Pryzby wrote: > > > As writen, this patch uses zstd level=1 (whereas the ZSTD's default compress > > level is 6). > > Why? ZSTD using this default has its reasons, no? And it would be > consistent to do the same for ZSTD as for the other two methods. In my 1-off test, it gets 610/633 = 96% of the benefit at 209/273 = 77% of the cost. postgres=# SET wal_compression= 'zstd-6'; postgres=# \set QUIET \\ \timing on \\ SET max_parallel_maintenance_workers=0; SELECT pg_stat_reset_shared('wal'); begin; CREATE INDEX ON t(a); rollback; SELECT * FROM pg_stat_wal; Duración: 2729,017 ms (00:02,729) wal_bytes | 6102403 postgres=# SET wal_compression= 'zstd-1'; postgres=# \set QUIET \\ \timing on \\ SET max_parallel_maintenance_workers=0; SELECT pg_stat_reset_shared('wal'); begin; CREATE INDEX ON t(a); rollback; SELECT * FROM pg_stat_wal; Duración: 2090,459 ms (00:02,090) wal_bytes | 6330269 It may be relevant that we're only compressing 8k [0]. It would probably pay off to preserve a compression "dictionary" to be re-used across FPIs. > - The supported methods are pglz and > - lz4 (if PostgreSQL was > - compiled with ). The default value is > - off. Only superusers can change this setting. > + The supported methods are pglz, and > + (if configured when PostgreSQLwas built) > + lz4 and zstd. > + The default value is off. > + Only superusers can change this setting. > > This is making the docs less verbose. I think that you should keep > the mention to respectively --with-lz4 and --with-zstd after each > value. I changed this relative to your latest zstd patch in July since it reads better to me. YMMV. On Tue, Feb 22, 2022 at 05:19:48PM -0600, Justin Pryzby wrote: >> 0001 adds support for zstd >> 0002 makes more efficient our use of bits in the WAL header >> 0003 makes it the default compression, to exercise on CI (windows will fail). >> 0004 adds support for zstd-level >> 0005-6 are needed to allow recovery tests to pass when wal compression is enabled; >> 0007 (not included) also adds support for zlib. I'm of the impression nobody >> cares about this, otherwise it would've been included 5-10 years ago. > 0003, defaulting to zstd, would require a lot of benchmarking to be > justified. Maybe you didn't see that I wrote that it was for CI ? (In any case, it's impossible to do that without first taking care of 005-6). > and 0004 to extend compression to support a level > I have argued against making the code more complicated for such things in the > past, with reloptions. I suppose that you're referring to reloptions for toast compression, which was about controlling LZ4 compression level. https://www.postgresql.org/message-id/flat/CAFiTN-vMHU_yakMgNo90SUih_6LtvmqZ5hpQb2iTgQtVyOjyFA@mail.gmail.com I think you're right that it's not interesting to control the compression level of LZ4 - but there's no reason to say the same thing of zstd. We're already debating which is the "right" level to use (1 or 6). I don't think there is a "right" level - some people will want to trade more CPU for disk writes and some people won't.