Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4900468imu; Tue, 29 Jan 2019 09:20:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN4iIF6paHV9Suz1kYXscmxSIM2peia+YuIXyUjezuEQD9JqMxsdZYGDjXgeeMWWa/Hs1r+P X-Received: by 2002:a63:c141:: with SMTP id p1mr24450465pgi.424.1548782422110; Tue, 29 Jan 2019 09:20:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548782422; cv=none; d=google.com; s=arc-20160816; b=EkEJkEmJvk08wuTl/5WwmYbqX/UHpRi1+5sBy2GxFNK/jLOMf5Tm8dCerI4xPRiCoJ Yt1AYFMMWKaluBxGjaqNzqwYfmHKPK+JNyhX5MSsv9p1D3C6ZAVkBX/vZzrVrShMEu+l P6ITurQYs9PL7fmhHskgjekQoA/7ZYKieOfnJJODy1+RFCqOWnItGbCoOdT33CEDjbfI 7QfFvd9FXiphzxbeZ5u3wSHGfDmOSUaX/20taWDxojDyuSXMBJKjubegyQp5O2zU/ZZv lxNY/zRWicopP1qdXGHTGDm8JGwX3e5gsCvHgwQ3DRHIWt+AyFnpitO5qTjsUbcgLhGL bJzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :reply-to:message-id:subject:cc:to:from:date; bh=IM6LojRo7mKyJSXB5IfGD2Xp/NnKQktTPPqNCPnGIZ0=; b=l0TYGxIt9RtgX7gaOQJRbJ9tuGAShmVGztkrtXKyt4ftreRwT5Rm8COiQFTn/XOx2D lE8qlrE4Sn5Dl4xvxCAPivLY7yODx7Lk1mcTHp32O8Z+2WBXAzO+IQ035/mqVG5t0bKv Vfhhw8TUYqJVGnmLpAXtYgI8UqOg8Te7Np0eqEIGAkVah1uwbxwTqU2/oAJnuIQ4pt3C FEtj703ShuOqhA7jhErVFvybT5FKw49DU/iB/vf/QVszPMOo4Gq2pBzABUmyqqr9lvSa O5SQ37z/bPMfa6D3HEEx0gp1kB4ZoAN4fr+bkR6NWWmcjsjV8yEEJavxFhG085a81zJF vOAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i1si5196056pgr.569.2019.01.29.09.20.01; Tue, 29 Jan 2019 09:20:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729117AbfA2RTL (ORCPT + 99 others); Tue, 29 Jan 2019 12:19:11 -0500 Received: from mx2.suse.de ([195.135.220.15]:37006 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727100AbfA2RTL (ORCPT ); Tue, 29 Jan 2019 12:19:11 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 41DB4B033; Tue, 29 Jan 2019 17:19:09 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 07124DA78C; Tue, 29 Jan 2019 18:18:31 +0100 (CET) Date: Tue, 29 Jan 2019 18:18:30 +0100 From: David Sterba To: Dennis Zhou Cc: David Sterba , Josef Bacik , Chris Mason , Omar Sandoval , Nick Terrell , kernel-team@fb.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 00/11] btrfs: add zstd compression level support Message-ID: <20190129171830.GP2900@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Dennis Zhou , David Sterba , Josef Bacik , Chris Mason , Omar Sandoval , Nick Terrell , kernel-team@fb.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190128212437.11597-1-dennis@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190128212437.11597-1-dennis@kernel.org> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 28, 2019 at 04:24:26PM -0500, Dennis Zhou wrote: > As mentioned above, a requirement that differs zstd from zlib is that > higher levels of compression require more memory. To manage this, each > compression level has its own queue of workspaces. A global LRU is used > to help with reclaim. To guarantee forward progress, a max level > workspace is preallocated and hidden from the LRU. Here I'd like to bring up what was mentioned in previous iteration, the workspace sizes. Level Compression Memory 1 0.8 MB 2 1.0 MB 3 1.3 MB 4 0.9 MB 5 1.4 MB 6 1.5 MB 7 1.4 MB 8 1.8 MB 9 1.8 MB 10 1.8 MB 11 1.8 MB 12 1.8 MB 13 2.3 MB 14 2.6 MB 15 2.6 MB and decompression needs memory of level 1. The sizes can be grouped together to say 3 sizes, I'm not sure that we'd really need 15 distinct workspaces. The reclaim mechanism helps, but I'd rather keep a smaller number of workspaces that covers average use. Default level is 3, that's 1.3 MiB, that also covers level 1, 2 and 4. For 5 to 12 it's 1.8 and the rest is 2.6 MiB. > btrfs filesystem 10 times and then read back after dropping the caches. > The btrfs filesystem was on an SSD. > > Level Ratio Compression (MB/s) Decompression (MB/s) > 1 2.658 438.47 910.51 > 2 2.744 364.86 886.55 > 3 2.801 336.33 828.41 > 4 2.858 286.71 886.55 > 5 2.916 212.77 556.84 > 6 2.363 119.82 990.85 > 7 3.000 154.06 849.30 > 8 3.011 159.54 875.03 > 9 3.025 100.51 940.15 > 10 3.033 118.97 616.26 > 11 3.036 94.19 802.11 > 12 3.037 73.45 931.49 > 13 3.041 55.17 835.26 > 14 3.087 44.70 716.78 > 15 3.126 37.30 878.84 From my casual user's perspective, I'd use the level 1 for speed, 7 for better ratio and 15 for the best compression. Anything else does not look good, though the results would vary based on the data set. I assume that the silesia corpus serves as a good approximation of the worst case average. The levels 7-14 strike particularly obvious pattern: same ratio but the speed gets worse with each level. Taking the default level into account, (my) recommended levels would be 1, 3, 7, 15. I went through the patches, looks mostly ok, I don't like the indirections but at the moment it's an implementation detail as I'd like to agree on the overall approach first. We might need a few revisions or cleanup rounds to converge to an efficient solution, the advantage here is that it's all in-memory and without compatibility concerns once the level support for zstd is in and works. For that reason, I'm not opposed to the current version of the patchset. Given the time in development schedule, it's really close to code freeze, but the functionality has a narrow scope so I'm tentatively counting with it for 5.1.