| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
原始链接: https://news.ycombinator.com/item?id=43949134
Daniel Cota 推出了 LoopMix128,这是一个针对非密码学任务设计的快速 C 语言伪随机数生成器。其速度约为 0.37 ns/值,显著快于 xoroshiro128++ 和 PCG64,同时通过了 TestU01 BigCrush 和 PractRand (32TB) 的测试。该 PRNG 保证了 2^128 的周期,并使用 192 位状态,通过 Z3 SMT 求解器证明了其在并行流中的单射性。 MurmurHash 的作者 Aappleby 对其通过 BigCrush 测试感到惊讶,并指出状态更新函数的近线性性。他们质疑需要 2^128 周期的保证,并建议为这类应用使用更强大的生成器。 Straw 建议进行状态大小容量分析,以更好地了解其强度。其他用户将 LoopMix128 的性能与 PCG64、RomuQuad 和 RomuDuoJr 进行了比较。结果发现它比 PCG64 快,与 wyrand 相当,比 RomuDuoJr 稍慢。 作者正在根据最近的评论更新代码,并发现了一个反例,很快就会修复。
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The state update function is effectively "a = rotate(a, constant) + b; b = rotate(b, constant) + constant;" and the output derivation is "output = (a + b) * constant".
That update function is _barely_ nonlinear, and the output derivation is linear. The output would probably be slightly better as "(a ^ b) * constant".
The slow_loop thing to guarantee 2^128 period is probably not needed - anyone with an application that cares about a period that high is probably going to choose a more robust generator (a few rounds of hardware-accelerated AES in counter mode is your best bet there)
The use of the Z3 prover is neat and I should read up on that more.
reply