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

Implement support for random seeds for fully reproducible results #3

Closed
mlist opened this issue Oct 26, 2018 · 3 comments
Closed

Implement support for random seeds for fully reproducible results #3

mlist opened this issue Oct 26, 2018 · 3 comments
Labels

Comments

@mlist
Copy link
Collaborator

@mlist mlist commented Oct 26, 2018

No description provided.

@mlist mlist added the enhancement label Oct 26, 2018
@mlist

This comment has been minimized.

Copy link
Collaborator Author

@mlist mlist commented Oct 26, 2018

A classical random number generators used across threads leads to massive performance degradation due to concurrent access. To alleviate this, Java uses ThreadLocalRandom as a substitute which is thread-safe and efficient. The problem now is that ThreadLocalRandom does not support setting seeds. In general, it is difficult to ensure that results are fully reproducible in parallel execution. Even if every thread uses its own number generators, we can not guarantee the exact order of triplets tested since this depends on the somewhat random execution speed of each thread...

In summary, we can use random seeds but this will make things considerably slower...

@mlist

This comment has been minimized.

Copy link
Collaborator Author

@mlist mlist commented Oct 26, 2018

An alternative for ThreadLocalRandom is proposed here:
https://hal.inria.fr/hal-01098598/document

https://github.com/jopasserat/tasklocalrandom

@mlist

This comment has been minimized.

Copy link
Collaborator Author

@mlist mlist commented Oct 26, 2018

After playing with the BetterRandom library for a while I now simply implemented the following:

if the user sets a seed, for each triplet a local Random number generator will be started with that seed, making the results reproducible.

If a seed is not set, ThreadLocalRandom() is used to coordinate random seeding across all threads, leading to a more random shuffling.

@mlist mlist closed this in 9ff2da0 Oct 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.