mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-04-06 17:49:11 +03:00
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 <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de> Signed-off-by: Shengqi Chen <harry-chen@outlook.com> Closes #16131 Closes #16483
This commit is contained in:
parent
4d469acd17
commit
1c35206124
@ -66,6 +66,7 @@
|
|||||||
#include "zfs_namecheck.h"
|
#include "zfs_namecheck.h"
|
||||||
#include <sys/vdev_impl.h>
|
#include <sys/vdev_impl.h>
|
||||||
#include <sys/arc.h>
|
#include <sys/arc.h>
|
||||||
|
#include <cityhash.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Needed to close a window in dnode_move() that allows the objset to be freed
|
* 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)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The hash is a CRC-based hash of the objset_t pointer and the object number.
|
* Runs cityhash4 on the objset_t pointer and the object number.
|
||||||
*/
|
*/
|
||||||
static uint64_t
|
static uint64_t
|
||||||
dnode_hash(const objset_t *os, uint64_t obj)
|
dnode_hash(const objset_t *os, uint64_t obj)
|
||||||
{
|
{
|
||||||
uintptr_t osv = (uintptr_t)os;
|
uintptr_t osv = (uintptr_t)os;
|
||||||
uint64_t crc = -1ULL;
|
return (cityhash4((uint64_t)osv, obj, 0, 0));
|
||||||
|
|
||||||
ASSERT(zfs_crc64_table[128] == ZFS_CRC64_POLY);
|
|
||||||
/*
|
|
||||||
* The lower 11 bits of the pointer don't have much entropy, because
|
|
||||||
* the objset_t is more than 1KB long and so likely aligned to 2KB.
|
|
||||||
*/
|
|
||||||
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (osv >> 11)) & 0xFF];
|
|
||||||
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (obj >> 0)) & 0xFF];
|
|
||||||
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (obj >> 8)) & 0xFF];
|
|
||||||
crc = (crc >> 8) ^ zfs_crc64_table[(crc ^ (obj >> 16)) & 0xFF];
|
|
||||||
|
|
||||||
crc ^= (osv>>14) ^ (obj>>24);
|
|
||||||
|
|
||||||
return (crc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int
|
static unsigned int
|
||||||
|
Loading…
Reference in New Issue
Block a user