Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp658301rbb; Sat, 24 Feb 2024 19:18:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUmcwvG/RuObd66sIPhClqoXf+Ud6k2Ej9DdVEML/Sudb/Y5TzQ6IYKZl3wRNgcTeHC0yGtfgCpIA7p0Xb+tHBmTvMhMTER7r+9M4N9FA== X-Google-Smtp-Source: AGHT+IFShZ7lDf/aJgr+Q5FO0EGaM2ggAIQIVU+2nZXMQsI9VT3NQcFAxYHZ+aZqUYM2VdFQSQlh X-Received: by 2002:a17:906:f44:b0:a3e:a712:ba9d with SMTP id h4-20020a1709060f4400b00a3ea712ba9dmr2572690ejj.4.1708831132645; Sat, 24 Feb 2024 19:18:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708831132; cv=pass; d=google.com; s=arc-20160816; b=zubLHdW8zQdwjYs6Lj19rry6OyYl4DMYBnh+HMRkkWh+mEZwCoc8aOCsrLom6JtpTP vk2pV89Ap2M9T5Kmef+fg96joe09Wxnfc73AZ+6b6Gl+WjKSBXpQc9tvfuDs4+HCIGvY mrZUaRJzJ7dVRfaPw/9vDHRgtIqsg5BIf8om8q0a58EpwyPFvuun9CKWE6B7VBK3cRE6 6eyLRwX+IIQ0YM7oqId9m2XK1HMDyAaVXx0LsYYokWG2IQuoJeLmSwqzMeV++6sRpSC9 LHtsKtv4GxsDF8FcYDvCHyowMivfnpf5RMh15ZF4f5rDJ8N08e37FbwbD/85GaOu1eZa ifaQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=ZFn6W6U4L0su1Wfy+lZLYSD3C6FtmzaANUHZ73XSo8o=; fh=yEeywzTE8hb4iMypOMCi/jp2FrqqJmS7fjgkDg2QdQs=; b=RkZDrA09KuHWeeTyUdKMBNy5u13Rlqb+3geyHrRp5BykYtEwwPS9OCF3XMGmScpgex RFecdruZ37A4zBF6eCBIsON88BaRzUpakzTBLSLiPDb6IEaCMZgoT6sTp+jy3F3wDWAv UsPYCRFeh+MPGf2le+7mv/5rVk3NEwfeFkEa2hInlm0qIoAd5reMIxdirZ6FHZpf86H4 JfxbNOVz5QzwHTcKOUe8XD4OyuRDuyTs2rfcbHH48i7EnZ8mzLitGPfaoTpCzH2mZo4N W0SDmpT6/nZowgOd06RaMdi8Z97qsAk6A9InxYcICG+m4WTxlAVlqA5Q+TS3WXv8KF6I 34JA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=TtTotn1Z; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-79958-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79958-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lf11-20020a170907174b00b00a3d95693200si967731ejc.591.2024.02.24.19.18.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 19:18:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79958-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=TtTotn1Z; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-79958-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79958-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 665371F215A0 for ; Sun, 25 Feb 2024 03:18:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E674E8BF7; Sun, 25 Feb 2024 03:18:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="TtTotn1Z" Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F04A53A0 for ; Sun, 25 Feb 2024 03:18:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708831119; cv=none; b=lZG2EF6zRC2FJVoG4UEoIRlj1Khk3t2NiFnM0en65I/xLIRJdN0b1bkRcrXNaYuw5ScHJz7eBQViSCYWOecYOHzBLS+6TrY1e6rAJM6q0Doye/yjvAUUGXciVxqOpVTHEZckIvSjXSSx7IK9qbH+XE6szPzpjvoMNRXYZ6pt/3w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708831119; c=relaxed/simple; bh=H6aDVYj/xJAeBB4FwsyU9gVzxd5e8XFBkWclh4nutxU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=n9nDinX4860j+YMvLeHg29utSIJSrpQ6lwrObxSYshEWs2gk5fK7u36DFfU/62W2p1LwYYZmvF91pyQpu0bmx/dHH22ztU94jn5RbZsaWmuCKCK4As8qjSUDSUw9p+ikV4WHDBQjtOWnHdvxxU66h9N7PZpVdRIx2Q3Q6uhK8Kk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=TtTotn1Z; arc=none smtp.client-ip=95.215.58.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Sat, 24 Feb 2024 22:18:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708831115; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZFn6W6U4L0su1Wfy+lZLYSD3C6FtmzaANUHZ73XSo8o=; b=TtTotn1Zt7Oioseodlv67q6zr9SBuqavSMX1nUmBb4idYhnyma3q5JhSBaE9ICRZmiRzSm 4Drn0ijg1NjwxZKo/uOP3C7lC+PU++Gr//SaDHpnX2Gx2+nN4ZQNYITNBk2Xs+gqqijeFf iCIvatgD8wiNm4CrIepy4PmqSBDsxyM= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: David Laight Cc: 'Herbert Xu' , "Matthew Wilcox (Oracle)" , "linux-kernel@vger.kernel.org" , Thomas Graf , "netdev@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "maple-tree@lists.infradead.org" , "rcu@vger.kernel.org" Subject: Re: [PATCH 0/1] Rosebush, a new hash table Message-ID: <2s73sed5n6kxg42xqceenjtcwxys4j2r5dc5x4fdtwkmhkw3go@7viy7qli43wd> References: <20240222203726.1101861-1-willy@infradead.org> <4a1416fcb3c547eb9612ce07da6a77ed@AcuMS.aculab.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4a1416fcb3c547eb9612ce07da6a77ed@AcuMS.aculab.com> X-Migadu-Flow: FLOW_OUT On Sat, Feb 24, 2024 at 10:10:27PM +0000, David Laight wrote: > From: Herbert Xu > > Sent: 24 February 2024 00:21 > > > > On Thu, Feb 22, 2024 at 08:37:23PM +0000, Matthew Wilcox (Oracle) wrote: > > > > > > Where I expect rosebush to shine is on dependent cache misses. > > > I've assumed an average chain length of 10 for rhashtable in the above > > > memory calculations. That means on average a lookup would take five cache > > > misses that can't be speculated. Rosebush does a linear walk of 4-byte > > > > Normally an rhashtable gets resized when it reaches 75% capacity > > so the average chain length should always be one. > > The average length of non-empty hash chains is more interesting. > You don't usually search for items in empty chains. > The only way you'll get all the chains of length one is if you've > carefully picked the data so that it hashed that way. > > I remember playing around with the elf symbol table for a browser > and all its shared libraries. > While the hash function is pretty trivial, it really didn't matter > whether you divided 2^n, 2^n-1 or 'the prime below 2^n' some hash > chains were always long. that's a pretty bad hash, even golden ratio hash would be better, but still bad; you really should be using at least jhash. you really want a good avalanche effect, because in real world usage your entropy is often only in a relatively few bits. when I implemented cuckoo (which is more obviously sensitive to a weak hash function), I had to go with siphash, even jhash wasn't giving me great reslts. and looking at the code it's not hard to see why, it's all adds, and the rotates are byte aligned... you want mixed adds and xors and the rotates to be more prime-ish. right idea, just old... what would be ideal is something more like siphash, but with fewer rounds, so same number of instructions as jhash. xxhash might fit the bill, I haven't looked at the code yet...