Skip to content

Commit a74282e

Browse files
committed
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. See: #16131 Signed-off-by: Shengqi Chen <[email protected]>
1 parent 50b32cb commit a74282e

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

module/zfs/dmu_objset.c

Lines changed: 3 additions & 17 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
@@ -390,27 +391,12 @@ dmu_objset_byteswap(void *buf, size_t size)
390391
}
391392

392393
/*
393-
* The hash is a CRC-based hash of the objset_t pointer and the object number.
394+
* Runs cityhash4 on the objset_t pointer and the object number.
394395
*/
395396
static uint64_t
396397
dnode_hash(const objset_t *os, uint64_t obj)
397398
{
398-
uintptr_t osv = (uintptr_t)os;
399-
uint64_t crc = -1ULL;
400-
401-
ASSERT(zfs_crc64_table[128] == ZFS_CRC64_POLY);
402-
/*
403-
* The lower 11 bits of the pointer don't have much entropy, because
404-
* the objset_t is more than 1KB long and so likely aligned to 2KB.
405-
*/
406-
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (osv >> 11)) & 0xFF];
407-
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (obj >> 0)) & 0xFF];
408-
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (obj >> 8)) & 0xFF];
409-
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (obj >> 16)) & 0xFF];
410-
411-
crc ^= (osv>>14) ^ (obj>>24);
412-
413-
return (crc);
399+
return cityhash4((uint64_t)os, obj, 0, 0);
414400
}
415401

416402
static unsigned int

0 commit comments

Comments
 (0)