-
-
Notifications
You must be signed in to change notification settings - Fork 449
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
Add guaranteed-reproducible PRNGs to rand? #1588
Comments
If you want guaranteed reproducibility can't you just use the named PRNG? Maybe I am misunderstanding the question. |
Yes — except that none of those named PRNGs are currently publicly export from Motivation is partially convenience and partially to make it more obvious how users may set up a reproducible PRNG (currently another crate must be added as a dependency). |
Ah true, I remember having to do this. I would say exporting |
As argued in the linked issue, I don't think we need it and we should recommend use of a concrete PRNG crate (we could reference them in |
When I'm sufficiently worried about long-term reproducibility that I'd opt for a generator with such a guarantee, I generally wouldn't be satisfied if the guarantee only covered So I think rand, as a general-purpose crate that has good reasons to make value-breaking changes from time to time, is not in a good position to try and address the need for reproducibility. Offering it only for the simple cases, but not for the other APIs that come along for the ride, will result in just as many people being mistaken about whether their |
The same is true of any library offering a wide variety of random algorithms? The solution here is simple enough: use a fixed version of |
Using a fixed version is not great because it means I'll effectively be on my own with maintaining that code once upstream (quite reasonably) stops doing so. Whether value-breaking changes are made in patch releases or only in minor releases is immaterial -- eventually I'll have to choose between eating a value-breaking change or sticking with an unmaintained version of the library. This won't be an issue if my code stops being actively developed before upstream moves on, but in many cases I don't want to make assumptions about that. And if I end up having to vendor the library, I'd always prefer one that is as small and simple as possible for my specific use case over a library that does basically everything. The only way around this is if a library is aligned with my priorities w.r.t. reproducibility: making a credible promise to avoid value-breaking changes, by only adding new APIs without changing the old ones (possibly deprecating them but ideally without the implication that they'll be removed eventually). Of course, that's undesirable for everyone who doesn't need long-term reproducibility and wants to get improvements automatically. But it's not inherently impossible for a maintainer to do that, if that's their priority. |
If you're talking about (I'm assuming you're not talking about maintenance of security — but even here nothing of note happened in the last four years, and if it did I expect that we would release a patch.) So I don't buy your argument that |
I don't know how easy or hard it would be for me to take over bugfix-only maintenance of a specific In any case, if I'm happy to use a fixed version of a library then it doesn't matter if the library offers reproducibility guarantees across its releases (of course, consistent results across platforms still matter). If I'll be using rand 0.8.5 forever, then I'm not affected by value-breaking changes in later releases. Conversely, if I want to avoid pinning a specific version and instead keep updating rand, then I need reproducibility guarantees for all APIs that I'm using or might use by accident in the future, not just for the |
This question came up recently regarding a possible adoption to
libstd
(read from here), but I'm not sure we ever really asked the question ofrand
.StdRng
andSmallRng
are deterministic but not reproducible (and in the latter case also not portable). Should we add a PRNG with guaranteed reproducibility as a new item underrand::rngs
?We already have five PRNGs available in
rand
if you count the ChaCha variants:ChaCha8Rng
,ChaCha12Rng
,ChaCha20Rng
Xoshiro128PlusPlus
,Xoshiro256PlusPlus
I'm not sure if we should ever add a guaranteed-reproducible ChaCha PRNG in
rand
since if we ever wanted to change the generator behindThreadRng
it would add dependencies. Given how long we've been using ChaCha in this role this may be less of an issue now.The Xoshiro variants are more acceptable (if only because they require a lot less code; both are directly implemented in
rand
), though selecting one of these is likely sufficient, e.g.rang::rngs::Xoshiro256PlusPlus
.CC @hanna-kruppe @joshtriplett in case of interest
The text was updated successfully, but these errors were encountered: