做了个需求,需要使用哈希值来确定一个唯一 seed 然后利用这个 seed 去得到随机值。 排查问题发现在不同机器上返回的值不同(预期是 seed 一致返回的值一定相同)。问题排查 但由于偷懒直接用了 hashbrown 自带的 DefaultHasherBuilder。 而他是使用的 ahash。 我并没有去过多的了解 ahash 的具体适用场景,也就是发生问题后才知道原来 ahash 的哈希结果只在同一个进程中哈希相同的值可以做到唯一性,而我把它用在了不同的机器上(😂😂)。 具体可以看 READMEBecause it does not have a fixed standard, different computers or computers on different versions of the code will observe different hash values. As such, aHash is not recommended for use other than in-memory maps. Specifically, aHash is not intended for network use or in applications which persist hashed values. (In these cases `HighwayHash` would be a better choice) 具体查看发现其实是内部哈希获取 seed 的时候调用了这个: https://docs.rs/ahash/latest/ahash/random_state/trait.RandomSource.html 。。。 mt 也说就算 seed 是你自定义传给他一致的,也可能因为 CPU 不同(指令集的支持程度不同)等问题发生不一致。。。 所以解决方案还得是使用 HighwayHash