smol-rs / fastrand

A simple and fast random number generator
Apache License 2.0
386 stars 33 forks source link

Use wyrand final v4.2 constants for gen_u64() #82

Closed Bluefinger closed 4 months ago

Bluefinger commented 5 months ago

BREAKING CHANGE

This PR introduces updates to fastrand's Wyrand algorithm, primarily using updated constants from the final v4.2 implementation of wyhash. This modification of the constants means the output of the generator is different, hence the breaking change. Based on the C reference, the new constants are generated using the same secrets algorithm but with a modification to ensure the constants are also large prime numbers. This additional property has helped improve the quality of the hashing for wyhash and the reference wyrand function.

Given the wide usage of fastrand, improving the quality of the generated output will be a nice plus, especially if it does not involve any performance hits (since fastrand is about being fast). But it will necessitate a new major version as anyone relying on deterministic output will have different generated sequences compared to before.

Reference: C reference wyrand function