Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3194655ybc; Mon, 18 Nov 2019 11:06:12 -0800 (PST) X-Google-Smtp-Source: APXvYqy7UsG9DvAYSi2DAGAA38wN7eQHUI4QsfFfhaUnbghv2N1lhKrdmI0OgjZGjkvpdpu9+EsJ X-Received: by 2002:a1c:6588:: with SMTP id z130mr687862wmb.87.1574103972496; Mon, 18 Nov 2019 11:06:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574103972; cv=none; d=google.com; s=arc-20160816; b=WxLfhzv5nvS9dFWIUDj+rbvcHgR0PegdGxPsgXoDYSBRHts3E166ImtHT9AYzVelvw 1h013GSVNlNeZVHzuPmONAe0gxsFFGKrGB2L6bd4CGUF8vSCFLfZfpQP90WJw7SjZsHj L24NvnhdzPLI4Phpw06mi9XE6o3AXvRiR55ikEip/ms2m010qvoVz4su5/tmidqUs/ld uAlB0RJikJ7jOnaHiShpxiEtDBs9nCXPwCBuHuthvcX7Ttk/bHc3ZvtRo3R3OLbd3MEC k4HWks5UoTEssy5LqBXh6xmskg48dK2QkffOl70MNswcZY5wakvTbEWc3L4c+4cyqXhZ Pk6g== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=g7UeeAiDpLXIZyawULy9LChbDuT/bywV3sjowK/21oA=; b=HMc/dX+0cu+050uV/1GshuE1Pdj43pLwh16Lyv9+T0rqHVGc3NqK+uHyWzCU3dVGso /dAggK+jJf6YoRnTlEUgUC7f38fiIoDYUFOF0Kl+HbdcAEJeZDR8P9czxY0MfRZpKjG8 WNmoxbvNZpyL2tNDNgETGHdDYj6/AR3qenYusMZZ7ATPY1f+WjADjoaya7ikO2Fr4vYy gSLly1+mO3aJsZyuYZwm4YkimVmBFdb6fH8nx2sGYY9T8Foc1GW/EsuxXgTH+WtRZQ+l OsA+O8hP75uF4MNAfLzaWzZo5079ovjb20BAcxjB9/AwUCK+NNyV360B6YcfRMVZZRiz bdgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@purestorage.com header.s=google header.b=CFzGLpEv; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=purestorage.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p17si12334259edm.269.2019.11.18.11.05.42; Mon, 18 Nov 2019 11:06:12 -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; dkim=pass header.i=@purestorage.com header.s=google header.b=CFzGLpEv; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=purestorage.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726695AbfKRTEe (ORCPT + 99 others); Mon, 18 Nov 2019 14:04:34 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42526 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726423AbfKRTEd (ORCPT ); Mon, 18 Nov 2019 14:04:33 -0500 Received: by mail-pg1-f194.google.com with SMTP id q17so10054828pgt.9 for ; Mon, 18 Nov 2019 11:04:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=g7UeeAiDpLXIZyawULy9LChbDuT/bywV3sjowK/21oA=; b=CFzGLpEvo9h0wavIJ3BvGjj0jIxdJfl3uvMW6e/3/t2n6cMtudA+A4GFwZADhoL3E7 z2YU0QkdAvSVsIByFtEpc8VmgrPBUyOtNkkWDXcSgqDMLrgm/16SLQ6Qy2wg++nqoQ8u voZe3/N/5SNSh94yGyJbvTZV/kWNwLyQMNDC8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; 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=g7UeeAiDpLXIZyawULy9LChbDuT/bywV3sjowK/21oA=; b=WXhaYu67EJhXO+lX1Cx1m3ctdSxOYVD0Mv7yvg4hN6ePzRvqjN3cHNW6w+kq8HHb5r 3waHu0Fj2KR1RriwhM4shra6UqBtIulpoqTCgztV5/F1F+cmV4euasutx72KmZeki5gL mLu/3GTs5OY62hrUd1HQ+DSbN0YwI1LodF8JbgmWV4iMNQJr5HZM2Igx8g0aZH0zwmD4 8MK5KmP/D7ezXl/KVo2WFCOE9seVtBzugLJEaXNtHxGisoFiMDaopk48h/xvfi3wW1z9 ykkUIJHTHpjg2q4Emm18SzS251xprL4NUPNYRG5GgPc/oAz93uM7YmeHDJVkZcVMKIZZ E4hw== X-Gm-Message-State: APjAAAUeeV6lHcY+pI/QIR4mfWv6qmEcjuo2epN2wJpz8xX0Y3c+AymH F5iF65DcG2qV/2ZGRRBqkJpMNGtGMhc= X-Received: by 2002:a63:1b4e:: with SMTP id b14mr927755pgm.280.1574103872977; Mon, 18 Nov 2019 11:04:32 -0800 (PST) Received: from cork ([64.84.68.252]) by smtp.gmail.com with ESMTPSA id d187sm5272521pgc.1.2019.11.18.11.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2019 11:04:32 -0800 (PST) Date: Mon, 18 Nov 2019 11:04:30 -0800 From: =?iso-8859-1?Q?J=F6rn?= Engel To: vitaly.wool@konsulko.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, ddstreet@ieee.org, akpm@linux-foundation.org, sjenning@redhat.com, johannes@sipsolutions.net Subject: Re: [PATCH] zswap: use B-tree for search Message-ID: <20191118190430.GA16134@cork> References: <20191117185332.18998-1-vitaly.wool@konsulko.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191117185332.18998-1-vitaly.wool@konsulko.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 17, 2019 at 08:53:32PM +0200, vitaly.wool@konsulko.com wrote: > From: Vitaly Wool > > The current zswap implementation uses red-black trees to store > entries and to perform lookups. Although this algorithm obviously > has complexity of O(log N) it still takes a while to complete > lookup (or, even more for replacement) of an entry, when the amount > of entries is huge (100K+). > > B-trees are known to handle such cases more efficiently (i. e. also > with O(log N) complexity but with way lower coefficient) so trying > zswap with B-trees was worth a shot. > > The implementation of B-trees that is currently present in Linux > kernel isn't really doing things in the best possible way (i. e. it > has recursion) but the testing I've run still shows a very > significant performance increase. > > The usage pattern of B-tree here is not exactly following the > guidelines but it is due to the fact that pgoff_t may be both 32 > and 64 bits long. > > Tested on qemu-kvm (-smp 2 -m 1024) with zswap in the following > configuration: > * zpool: z3fold > * max_pool_percent: 100 > and the swap size of 1G. > > Test command: > $ stress-ng --io 4 --vm 4 --vm-bytes 1000M --timeout 300s --metrics > > This, averaged over 20 runs on qemu-kvm (-smp 2 -m 1024) gives the > following io bogo ops: > * original: 73778.8 > * btree: 393999 Impressive results. Was your test done with a 32bit guest? If yes, I would assume results for a 64bit guess to drop to about 330k. > + if (sizeof(pgoff_t) == 8) > + btree_pgofft_geo = &btree_geo64; > + else > + btree_pgofft_geo = &btree_geo32; > + You could abuse the fact that pgoff_t is the same size as unsigned long and use the "l" suffix variant. But apart from the obvious abuse, the "l" variant hasn't been used before and the implementation appears to be buggy. So no complaints about your use of the interface. J?rn -- Cryptographic protocols should not be designed by a committee. -- Niels Ferguson & Bruce Schneier