Hash 为什么在Redis dict中将负载系数设置为1

Hash 为什么在Redis dict中将负载系数设置为1,hash,redis,hashmap,Hash,Redis,Hashmap,众所周知,在哈希表中,负载因子对于控制冲突非常重要 在Java/HashMap中,默认加载因子为0.75,在CPython/dict中,加载因子设置为 然而,在Redis/dict中,当dict\u can\u resize启用时,为什么 /* If we reached the 1:1 ratio, and we are allowed to resize the hash * table (global setting) or we should avoid it but the rati

众所周知,在哈希表中,负载因子对于控制冲突非常重要

在Java/HashMap中,默认加载因子为0.75,在CPython/dict中,加载因子设置为

然而,在Redis/dict中,当dict\u can\u resize启用时,为什么

/* If we reached the 1:1 ratio, and we are allowed to resize the hash
 * table (global setting) or we should avoid it but the ratio between
 * elements/buckets is over the "safe" threshold, we resize doubling
 * the number of buckets. */
if (d->ht[0].used >= d->ht[0].size &&
    (dict_can_resize ||
     d->ht[0].used/d->ht[0].size > dict_force_resize_ratio))
{
    return dictExpand(d, d->ht[0].used*2);
}

在我看来,负载系数应该小于1。由于可能存在高冲突率,高负载因子可能会增加查找成本。

高负载因子也会提高内存效率。Redis是一个内存数据库,它需要高效的内存。我认为Redis的作者已经做了一些基准测试来平衡内存使用和性能。

对不起,对于Redis负载系数为1的原因,我认为您的答案并不理想。