← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 10646.c · 生成模型:未记录

哈希函数兼顾防护成本

理解等级:高级

哈希表的哈希函数需要兼顾运行成本和面对不良键分布时的稳定性。默认配置偏重抵抗碰撞造成的性能退化。只有性能测量证实哈希是瓶颈时,才有依据考虑另一种实现,并评估输入来源及防护能力的变化。Rust 通过 BuildHasher 接入替代实现。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 常用集合 Updating a Hash Map · 查看原书依据

      By default, HashMap uses a hashing function called SipHash that can provide resistance to denial-of-service (DoS) attacks involving hash tables. This is not the fastest hashing algorithm available, but the trade-off for better security that comes with the drop in performance is worth it.

    参考来源

    - 位置:《The Rust Programming Language(第2版)》第08章 常用集合(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/c08.xhtml`,块 0214) - 结论依据:原文指出书中默认函数用于抵抗碰撞型拒绝服务,并给出基于测量更换的条件。 - 原始内容:By default, HashMap uses a hashing function called SipHash that can provide resistance to denial-of-service (DoS) attacks involving hash tables. This is not the fastest hashing algorithm available, but the trade-off for better security that comes with the drop in performance is worth it.