Skip to content

Adding a wyrand-based PRNG? #120

Description

@hoxxep

I recently spun rapidrand out of rapidhash and decided to benchmark and test it properly. It's a wyrand construction, and so perhaps could be argued that it's theoretically weaker than xoshiro++, but it still passes BigCrush and PractRand at 16TB and is twice as fast as xoshiro++ and SmallRng.

For non-cryptographic use cases, would we be interested in a rust-random wyrand implementation? I'm happy to create a PR in the rust-random/rng style adding a wyrand PRNG?

Benchmarks

M1 Max
RNG u64 u32 fill 1 KiB
rapidrand RapidRng 0.51 ns 0.51 ns 21.67 GB/s
fastrand Rng* 0.51 ns 0.52 ns 21.49 GB/s
turborand Rng* 1.25 ns 0.51 ns 21.56 GB/s
nanorand WyRand* 0.51 ns 0.51 ns 3.57 GB/s
rand SmallRng 1.13 ns 1.20 ns 7.05 GB/s
rand_xoshiro Xoshiro256PlusPlus 1.14 ns 1.19 ns 7.04 GB/s
rand_xoshiro Xoshiro256StarStar 1.30 ns 1.37 ns 5.84 GB/s
rand_pcg Pcg32 2.06 ns 1.02 ns 3.93 GB/s
rand_pcg Pcg64 1.64 ns 1.65 ns 4.81 GB/s
rand StdRng (ChaCha12) 4.11 ns 2.26 ns 2.02 GB/s
rand_chacha ChaCha8Rng 5.86 ns 3.04 ns 1.45 GB/s
rand_chacha ChaCha20Rng 13.24 ns 6.70 ns 0.62 GB/s

*wyrand-based PRNGs that use their own random traits outside of the rust-random ecosystem.

DigitalOcean x86 droplet (Intel, CPU-optimized, dedicated vCPU)
RNG u64 u32 fill 1 KiB
rapidrand RapidRng 0.62 ns 0.62 ns 7.97 GB/s
fastrand Rng 0.62 ns 0.62 ns 7.99 GB/s
nanorand WyRand 0.62 ns 0.62 ns 2.57 GB/s
rand SmallRng 1.18 ns 1.21 ns 6.62 GB/s
rand_xoshiro Xoshiro256PlusPlus 1.17 ns 1.21 ns 6.61 GB/s
rand_xoshiro Xoshiro256StarStar 1.26 ns 1.19 ns 6.92 GB/s
turborand Rng 2.10 ns 2.06 ns 8.04 GB/s
rand_chacha ChaCha8Rng 2.51 ns 1.44 ns 4.31 GB/s
rand_pcg Pcg64 2.08 ns 2.07 ns 4.14 GB/s
rand_pcg Pcg32 2.78 ns 1.31 ns 2.96 GB/s
rand StdRng (ChaCha12) 3.22 ns 1.88 ns 2.88 GB/s
rand_chacha ChaCha20Rng 5.00 ns 2.74 ns 1.83 GB/s

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions