From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8lFd-00016B-NF for qemu-devel@nongnu.org; Fri, 03 Jun 2016 05:18:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8lFZ-0008QX-CJ for qemu-devel@nongnu.org; Fri, 03 Jun 2016 05:18:44 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:42330) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8lFX-0008N6-0O for qemu-devel@nongnu.org; Fri, 03 Jun 2016 05:18:41 -0400 Date: Fri, 3 Jun 2016 05:18:28 -0400 From: "Emilio G. Cota" Message-ID: <20160603091828.GA5251@flamenco> References: <1464138802-23503-1-git-send-email-cota@braap.org> <1464138802-23503-11-git-send-email-cota@braap.org> <574B487B.5080200@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <574B487B.5080200@gmail.com> Subject: Re: [Qemu-devel] [PATCH v6 10/15] qht: QEMU's fast, resizable and scalable Hash Table List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Fedorov Cc: QEMU Developers , MTTCG Devel , Alex =?iso-8859-1?Q?Benn=E9e?= , Paolo Bonzini , Richard Henderson On Sun, May 29, 2016 at 22:52:27 +0300, Sergey Fedorov wrote: > I was just wondering if it could be worthwhile to pass a hash function > when initializing a QHT. Then we could have variants of qht_insert(), > qht_remove() and qht_lookup() which does not require a computed hash > value but call the function by themselves. This could make sense since a > hash value passed the the functions should always be exactly the same > for the same object. I considered this when designing the API. I think it's not worth having in qht; callers could have their own wrapper to do this though. For the only caller of qht that we have so far I don't see this as being worth the hassle. For instance, we couldn't use the same function for lookups and inserts/removals, since the hash function would look like: uint32_t hash_func(void *p) { TranslationBlock *tb = p; return tb_hash_func(tb->phys_pc, ...); } But for lookups we don't yet know *tb (that's what we're looking for!). All we have is the tb_desc struct that we use for comparisons. Thanks, Emilio