-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: Move RandomDevice to Base.CoreRandom #35894
Conversation
I agree this is a good idea, it seems important to have real randomness available in Base if we're serious about reliability of unique IDs in distributed systems. Along with #35872 we'll be able to move @rfourquet what do you think? |
Only tangentially related, but I'm not sure Base uses |
Ah, I trusted the comment in the code but I can't find any use by |
I don't have a strong opinion on this. Also, until we really become serious about making A last remark is concerning #34852 (which implements a task-local RNG). If this was about to land in the medium term, this might be another candidate for being the "rand provider of |
Tangentially related but is there a way that this can help with making |
I don't think so, as we still probably want On this topic, I thought recently that it might have been cleaner to have |
It looks like the only place Lines 252 to 258 in 8f512f3
I think |
I think this can be closed, as we now have |
In a recent conversation with @c42f (#35833 (comment), #35833 (comment)) it was brought up that
Base
has no reliable way to generate random numbers that cannot be accidentally interfered by the user. We used to(?) useCurrently, we use(edit)Libc.rand
for this purpose but it is not reliable as the user or other external library components may callsrand
.It's ideal to have a more reliable way to generate "true" random numbers. For example, I proposed to use uuid4 in #35833 as an underlying identifier of the local "context variable." Using
Libc.rand
may be enough but RNG that has no seeding is ideal to ensure the correctness of the program.To solve this problem, this PR moves
RandomDevice
fromRandom
toBase.CoreRandom
and exposes "mini"-Random
interface insideBase
.