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

Switch to Wyrand #14

Merged
merged 2 commits into from Jul 19, 2021
Merged

Switch to Wyrand #14

merged 2 commits into from Jul 19, 2021

Conversation

SabrinaJewson
Copy link
Contributor

@SabrinaJewson SabrinaJewson commented Mar 13, 2021

Wyrand is faster than PCG and also passes all of the tests.

PCG benchmarks:

test shuffle_fastrand   ... bench:         405 ns/iter (+/- 9)
test u32_fastrand       ... bench:      13,779 ns/iter (+/- 657)
test u8_fastrand        ... bench:      13,771 ns/iter (+/- 696)

Wyrand benchmarks:

test shuffle_fastrand ... bench:         225 ns/iter (+/- 2)
test u32_fastrand     ... bench:      11,464 ns/iter (+/- 317)
test u8_fastrand      ... bench:      12,402 ns/iter (+/- 304)

Closes #19

@taiki-e
Copy link
Collaborator

taiki-e commented Apr 14, 2021

It seems the current implementation of this PR vulnerable to some known bad seeds: wangyi-fudan/wyhash#100 ManDeJan/zig-wyhash#2 eldruin/wyhash-rs#6

@SabrinaJewson
Copy link
Contributor Author

Does this apply to the RNG? The wyhash maintainer recently removed the _wyp default secret, but the wyrand implementation still uses it.

@taiki-e taiki-e merged commit 6802d45 into smol-rs:master Jul 19, 2021
@taiki-e
Copy link
Collaborator

taiki-e commented Jul 19, 2021

Thanks!

@SabrinaJewson SabrinaJewson deleted the wyrand branch July 19, 2021 15:15
@taiki-e
Copy link
Collaborator

taiki-e commented Jul 19, 2021

Published in 1.5.0

@flyingmutant
Copy link

I'd say it is a bit careless to say that "wyrand passes all of the tests", it certainly does not. Wyrand can only generate a subset of all u64 values (see wangyi-fudan/wyhash#16), and even if we consider that to not be a problem by itself, it leads to easily detectable biases. For example, the number of duplicates you get is consistently much higher than expected from random data: https://gist.github.com/flyingmutant/cb69e96872023f9f580868e746d1128a

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

Successfully merging this pull request may close these issues.

Should Wyrand be considered?
3 participants