From owner-svn-src-user@FreeBSD.ORG Sat May 30 21:55:43 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E6701106566C; Sat, 30 May 2009 21:55:43 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D4C678FC16; Sat, 30 May 2009 21:55:43 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4ULthLq020405; Sat, 30 May 2009 21:55:43 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4ULth4u020404; Sat, 30 May 2009 21:55:43 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905302155.n4ULth4u020404@svn.freebsd.org> From: Kip Macy Date: Sat, 30 May 2009 21:55:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r193121 - user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 May 2009 21:55:44 -0000 Author: kmacy Date: Sat May 30 21:55:43 2009 New Revision: 193121 URL: http://svn.freebsd.org/changeset/base/193121 Log: reduce hash table collisions by switching from crc32 to jenkins as the hash function Modified: user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Modified: user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat May 30 21:52:56 2009 (r193120) +++ user/kmacy/releng_7_2_fcs/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat May 30 21:55:43 2009 (r193121) @@ -132,6 +132,7 @@ #include #include +#include static kmutex_t arc_reclaim_thr_lock; static kcondvar_t arc_reclaim_thr_cv; /* used to signal reclaim thr */ @@ -625,19 +626,25 @@ static void l2arc_hdr_stat_remove(void); static uint64_t buf_hash(spa_t *spa, const dva_t *dva, uint64_t birth) { - uintptr_t spav = (uintptr_t)spa; - uint8_t *vdva = (uint8_t *)dva; - uint64_t crc = -1ULL; - int i; - - ASSERT(zfs_crc64_table[128] == ZFS_CRC64_POLY); - - for (i = 0; i < sizeof (dva_t); i++) - crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ vdva[i]) & 0xFF]; - - crc ^= (spav>>8) ^ birth; + uint32_t hashinput[2 + 4 + (sizeof(uintptr_t)>>2)]; + int count = 2 + 4 + (sizeof(uintptr_t)>>2); - return (crc); + hashinput[0] = ((uint32_t *)&birth)[0]; + hashinput[1] = ((uint32_t *)&birth)[1]; + hashinput[2] = ((uint32_t *)dva)[0]; + + hashinput[3] = ((uint32_t *)dva)[1]; + hashinput[4] = ((uint32_t *)dva)[2]; + hashinput[5] = ((uint32_t *)dva)[3]; + hashinput[6] = ((uint32_t *)&spa)[0]; +#ifdef __LP64__ + hashinput[7] = ((uint32_t *)&spa)[1]; +#endif +/* + * "only" 32-bits, but this will suffice up 16TB of RAM (2^(32+12)) + * + */ + return (jenkins_hashword(hashinput, count, 0xCAFEBABE)); } #define BUF_EMPTY(buf) \