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

Don't abuse PRNG -> fix identifier generation when building on Windows #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hillu
Copy link

@hillu hillu commented Oct 22, 2021

Pseudorandom number generators need to be initialized only once.

Using the system time for this is Generally Fine, but re-initializing
the PRNG in a tight loop every time a random number is needed
significantly raises the odds that the same number sequence (or even
the same number) is returned every time.

Chances for this to happen on Windows are apparently much higher than
on Linux. Not sure why this is the case, my best guess is that the
clock used for Go's `time.Now()´ runs with coarser granularity.

Pseudorandom number generators need to be initialized only once.

Using the system time for this is Generally Fine, but re-initializing
the PRNG in a tight loop every time a random number is needed
significantly raises the odds that the same number sequence (or even
the same number) is returned every time.

Chances for this to happen on Windows are apparently much higher than
on Linux. Not sure why this is the case, my best guess is that the
clock used for Go's `time.Now()´ runs with coarser granularity.
@hillu
Copy link
Author

hillu commented Feb 7, 2022

@Tylous Is this PR at all interesting to you?

@Tylous
Copy link
Owner

Tylous commented Feb 9, 2022

This is needed for it to work on Windows as well as Linux and and OSX

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