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 1nRw8w-0007Mk-Vb for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Mar 2022 13:14: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 1nRw8v-0005Qg-7Y for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Mar 2022 13:14:17 +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 1nRw8u-0005QX-Rq for pgsql-hackers@lists.postgresql.org; Wed, 09 Mar 2022 13:14:16 +0000 Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nRw8s-0004W2-84 for pgsql-hackers@postgresql.org; Wed, 09 Mar 2022 13:14:16 +0000 Received: by mail-io1-xd36.google.com with SMTP id e22so2620978ioe.11 for ; Wed, 09 Mar 2022 05:14:14 -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:in-reply-to:user-agent; bh=RnoHb9afLmv0bxV25ISAv6czAyz3IhcOEj6XzoTvXrY=; b=o5jbDHv9ZFCB5Z1Ojzhk7BdtX3qrIV4b+6Q21TKYQKsAG7TRQ5mnK/E3EDbahHJ9cI E3GLnMK2sfVlAMD3TEkapIwsp9iRXG/aqyr0r67x0KfdGkXsnPrrIbT3nRMyoLb4cEbx lsYQrZSfmrO6Ep5UdiT9H6M7G8ZGUFLkAvdJ4w7weSYYtqdwadjiSiv7qyviz7b3rPpM reTtsu5RgDB8GCgRXtuH6v93V90gGoyh7u7W/8Li4gwpO5RVSXPuGEziPLpoRMiW7okz lUZo53+6uA91QYIQOg1dcESjISdgiFf4sxoPRPaFa0stv1SGsfjlKpjCJOSIMgBcMIKJ jJdA== 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:in-reply-to:user-agent; bh=RnoHb9afLmv0bxV25ISAv6czAyz3IhcOEj6XzoTvXrY=; b=J/tbo8pg4YoWItAQL2jiYlIOYrkZ8la7qpD4wNj4F4ECU7+RGaLmGOvlrBQ3ztiqTM TbZCFsgDleMEf9G7NNWnVVLab1pIpKdIx9xcORZPmir3tiJomR/pMPBU8MQqfO6oUtnf cH5pdhQg/mjFBAv+D8LUGeXKz42pbXTfA9C0SkVhWz6NeoBXUJ1zmz+4uDqXEdts5RQh IASWXCQyJ6cyjCW8JGTRxcYBdLvMzskxcHfHDa/1slyYj0JVhboMF5f9wxcO7tE72Otf MJzzbQlg10RWw9u1FXr+gP3R6OyQ9LobK/j4VmOLbCcuCBpiefA8GqxCbit4gBcp2UWR zZJg== X-Gm-Message-State: AOAM532uNe+rywY8PZP8H6ELipYeYvLPgJhzyK8w+z1zpRQ/rJmRobz4 4T8HouAEyWVPwvW425Y0MKbOAQ== X-Google-Smtp-Source: ABdhPJxsoGNq0AI0YGA6T222kFBLsXmpS/WT653hYJbVleb6DDh8k7bOQ4FlFhKz+xK5eOLGjbK0uQ== X-Received: by 2002:a5d:9d44:0:b0:645:b6e9:4bbb with SMTP id k4-20020a5d9d44000000b00645b6e94bbbmr15770024iok.77.1646831652506; Wed, 09 Mar 2022 05:14:12 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id q5-20020a056e0220e500b002c5ba03f8eesm1058402ilv.9.2022.03.09.05.14.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Mar 2022 05:14:12 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 5473D801246; Wed, 9 Mar 2022 07:14:11 -0600 (CST) Date: Wed, 9 Mar 2022 07:14:11 -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: <20220309131411.GZ27651@telsasoft.com> References: <20220222231948.GJ9008@telsasoft.com> <20220304114405.GK27651@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220304114405.GK27651@telsasoft.com> 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 05:44:06AM -0600, Justin Pryzby wrote: > 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. Actually, my test used zstd-6, rather than the correct default of 3. The comparison should have been: 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; Time: 2074.046 ms (00:02.074) 2763 | 2758 | 6343591 | 0 | 5 | 5 | 0 | 0 | 2022-03-05 05:04:08.599867-06 vs postgres=# SET wal_compression='zstd-3'; 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; Time: 2471.552 ms (00:02.472) wal_records | wal_fpi | wal_bytes | wal_buffers_full | wal_write | wal_sync | wal_write_time | wal_sync_time | stats_reset -------------+---------+-----------+------------------+-----------+----------+----------------+---------------+------------------------------- 2762 | 2746 | 6396890 | 274 | 274 | 0 | 0 | 0 | 2022-03-05 05:04:31.283432-06 => zstd-1 actually wrote less than zstd-3 (which is odd) but by an insignificant amount. It's no surprise that zstd-1 is faster than zstd-3, but (of course) by a smaller amount than zstd-6. Anyway there's no compelling reason to not use the default. If we were to use a non-default default, we'd have to choose between 1 and 2 (or some negative compression level). My thinking was that zstd-1 would give the lowest-hanging fruits for zstd, while minimizing performance tradeoff, since WAL affects interactivity. But choosing between 1 and 2 seems like bikeshedding.