Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xoroshiro128Plus slows down relative to Base MT with increasing sample size #68

Open
robsmith11 opened this issue May 23, 2020 · 1 comment

Comments

@robsmith11
Copy link

From what I've read, Xoroshiro is often suggested as the fastest RNG with decent random properties. Using the implementation here, I do see it beating Base's MT for small samples, but getting relatively slower as the sample size passes ~100:

julia> r0 = Random.default_rng();

julia> r1 = RandomNumbers.Xorshifts.Xoroshiro128Plus(1);

julia> @btime rand($r0);
  2.458 ns (0 allocations: 0 bytes)

julia> @btime rand($r1);
  1.925 ns (0 allocations: 0 bytes)

julia> @btime rand($r0, 8);
  41.771 ns (1 allocation: 144 bytes)

julia> @btime rand($r1, 8);
  34.454 ns (1 allocation: 144 bytes)

julia> @btime rand($r0, 128);
  171.495 ns (1 allocation: 1.14 KiB)

julia> @btime rand($r1, 128);
  180.105 ns (1 allocation: 1.14 KiB)

julia> @btime rand($r0, 10^7);
  6.606 ms (2 allocations: 76.29 MiB)

julia> @btime rand($r1, 10^7);
  25.872 ms (2 allocations: 76.29 MiB)

Is this to be expected? Perhaps this information could be added to the docs.

julia> versioninfo()
Julia Version 1.5.0-DEV.803
Commit 8ab87d2205 (2020-05-03 08:07 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 8
@milankl
Copy link
Contributor

milankl commented Sep 1, 2020

I observe the same

julia> @btime rand($Xor);    # Xoroshiro128Plus
  1.849 ns (0 allocations: 0 bytes)

julia> @btime rand($MT);    # Default MersenneTwister
  4.094 ns (0 allocations: 0 bytes)

for single Float64, but

julia> @btime rand($MT,10^7);
  11.891 ms (2 allocations: 76.29 MiB)

julia> @btime rand($Xor,10^7);
  19.607 ms (2 allocations: 76.29 MiB)

for large arrays. Using an i5 on a macbook air.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants