Skip to content

Import xoshiro crate - #642

Merged
dhardy merged 9 commits into
rust-random:masterfrom
vks:xoshiro
Dec 21, 2018
Merged

dhardy merged 9 commits into
rust-random:masterfrom
vks:xoshiro

Conversation

@vks

@vks vks commented Nov 14, 2018

Copy link
Copy Markdown
Contributor

This is based on the xoshiro crate with minimal modifications.

vks added 2 commits November 14, 2018 12:35
* This replaces the old xoshiro benchmarks.
* rand_xoshiro now uses the correct version of rand_core.
@vks
vks requested a review from dhardy November 14, 2018 13:08
@dhardy

dhardy commented Nov 14, 2018

Copy link
Copy Markdown
Member

Thanks. Might take me a couple of days to review.

We can update the doc and publish rand_xoshiro without a new rand release anyway.

@vks

vks commented Nov 14, 2018

Copy link
Copy Markdown
Contributor Author

Yeah, this is not urgent.

@dhardy dhardy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of annoying little points here...

but other than the API doc I see no real reason this should be in the same repo. Maybe we should revive small-rngs or make a new rngs? The same is true for rand_xorshift, _isaac and _chacha once the deprecated re-exports are removed.

The advantages are faster/simpler CI, less stuff in this repo, and a separate issue tracker. I think it would be worth it. Shall I import your existing repo, move the code to a sub-directory, and publish as rust-random/rngs?

Comment thread .travis.yml
- cargo test --manifest-path rand_isaac/Cargo.toml --features=serde1
# TODO: cannot test rand_pcg due to explicit dependency on i128
- cargo test --manifest-path rand_xorshift/Cargo.toml --features=serde1
- cargo test --manifest-path rand_xoshiro/Cargo.toml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 but you should also add to utils/ci/script.sh and appveyor.yml. Yeah, it's a pain to have to configure CI in three places 😦

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. Maybe we should automatically generate the scripts from from some declaration of crates.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, though not all the scripts are identical (for annoying reasons). Not something I want to spend time solving.

Comment thread benches/generators.rs Outdated
use rand_hc::{Hc128Rng, Hc128Core};
use rand_pcg::{Lcg64Xsh32, Mcg128Xsl64};
use rand_xorshift::XorShiftRng;
use rand_xoshiro::Xoshiro256StarStar;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like all variants represented in the benchmarks... which does bring up the question of whether we should have them here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is nice to compare the performance of all the generators in one place. This also reduces code duplication.

I'll add the other variants.

Comment thread rand_xoshiro/Cargo.toml Outdated
[package]
name = "rand_xoshiro"
version = "0.1.0" # NB: When modifying, also modify html_root_url in lib.rs
authors = ["Vinzent Steinberg <Vinzent.Steinberg@gmail.com>"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to include this in the main repo, then I'd prefer the same convention as the other crates (though you can include yourself in addition if you like).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, no problem.

Comment thread rand_xoshiro/LICENSE-MIT Outdated
@vks

vks commented Nov 21, 2018

Copy link
Copy Markdown
Contributor Author

Maybe we should revive small-rngs or make a new rngs?

Didn't we decide against that because of problems with the docs? I don't see how that changed. I don't really care in which repository this lives, but I would prefer the links in the docs to work.

@dhardy

dhardy commented Nov 21, 2018

Copy link
Copy Markdown
Member

Part for that reason, part because it was difficult having direct dependencies of rand in a different repo, when those dependencies require rand_core from this repo. Ok, it can stay here for now.

Comment thread rand_xoshiro/src/splitmix64.rs Outdated
// David Stafford's
// (http://zimbry.blogspot.com/2011/09/better-bit-mixing-improving-on.html)
// "Mix4" variant of the 64-bit finalizer in Austin Appleby's
// MurmurHash3 algorithm.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what the link is? This algorithm is SplitMix. Isn't the point of this implementation to reproduce output from the official version?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, the official version only supports generating u64 natively. This is a more efficient variant for generating u32.

Comment thread rand_xoshiro/src/xoroshiro128plus.rs Outdated
Comment thread rand_xoshiro/src/xoroshiro128starstar.rs Outdated
Comment thread rand_xoshiro/src/xoroshiro64star.rs Outdated
Comment thread rand_xoshiro/src/xoroshiro64starstar.rs Outdated
Comment thread rand_xoshiro/src/xoshiro128plus.rs Outdated
Comment thread rand_xoshiro/src/xoshiro128starstar.rs Outdated
Comment thread rand_xoshiro/src/xoshiro256plus.rs Outdated
Comment thread rand_xoshiro/src/xoshiro256starstar.rs Outdated
Comment thread rand_xoshiro/src/xoshiro512plus.rs Outdated
Comment thread rand_xoshiro/src/xoshiro512starstar.rs Outdated

@dhardy dhardy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for poor time estimate; apparently "a couple of days" can mean a month!

Looks good, but there are a lot of RNGs included. I specifically kept rand_pcg small because not many will be widely used and it keeps the dependencies of rand small.

@vks

vks commented Dec 17, 2018

Copy link
Copy Markdown
Contributor Author

AFAIK, this is likely not going to be a dependency of rand, so I implemented all the RNGs from the reference implementation. Which RNGs would you drop?

@dhardy

dhardy commented Dec 20, 2018

Copy link
Copy Markdown
Member

I guess there are no obvious candidates to drop. Apparently no-one else is opinionated on this, so lets just accept this as-is for now — although I am of the opinion that we should move this to another repository later (along with all other PRNGs not directly depended on by rand).

I'll leave this until tomorrow for any final comments.

@dhardy
dhardy merged commit 5a67e32 into rust-random:master Dec 21, 2018
benjamin-lieser pushed a commit to benjamin-lieser/rand that referenced this pull request Feb 5, 2025
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

Successfully merging this pull request may close these issues.

2 participants