Skip to content

Commit 1c35206

Browse files
Harry-Chenbehlendorf
authored andcommitted
dmu_objset: replace dnode_hash impl with cityhash4
As mentioned in PR #16131, replacing CRC-based hash with cityhash4 could slightly improve the performance by eliminating memory access. Replacing algorightm is safe since the hash result is not persisted. Reviewed by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Tino Reichardt <[email protected]> Signed-off-by: Shengqi Chen <[email protected]> Closes #16131 Closes #16483
1 parent 4d469ac commit 1c35206

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

module/zfs/dmu_objset.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
#include "zfs_namecheck.h"
6767
#include <sys/vdev_impl.h>
6868
#include <sys/arc.h>
69+
#include <cityhash.h>
6970

7071
/*
7172
* Needed to close a window in dnode_move() that allows the objset to be freed
@@ -404,27 +405,13 @@ dmu_objset_byteswap(void *buf, size_t size)
404405
}
405406

406407
/*
407-
* The hash is a CRC-based hash of the objset_t pointer and the object number.
408+
* Runs cityhash4 on the objset_t pointer and the object number.
408409
*/
409410
static uint64_t
410411
dnode_hash(const objset_t *os, uint64_t obj)
411412
{
412413
uintptr_t osv = (uintptr_t)os;
413-
uint64_t crc = -1ULL;
414-
415-
ASSERT(zfs_crc64_table[128] == ZFS_CRC64_POLY);
416-
/*
417-
* The lower 11 bits of the pointer don't have much entropy, because
418-
* the objset_t is more than 1KB long and so likely aligned to 2KB.
419-
*/
420-
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (osv >> 11)) & 0xFF];
421-
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (obj >> 0)) & 0xFF];
422-
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (obj >> 8)) & 0xFF];
423-
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (obj >> 16)) & 0xFF];
424-
425-
crc ^= (osv>>14) ^ (obj>>24);
426-
427-
return (crc);
414+
return (cityhash4((uint64_t)osv, obj, 0, 0));
428415
}
429416

430417
static unsigned int

0 commit comments

Comments
 (0)