[llvm] r211705 - Random Number Generator (llvm)

Stephen Crane sjcrane at uci.edu
Tue Jul 8 12:31:30 PDT 2014


On Tue, Jul 8, 2014 at 11:26 AM, Geremy Condra <gcondra at google.com> wrote:
> It seems much better to me to use a CPRNG than to rely on something like MT,
> which has significant weaknesses despite its long period. As long as I can
> hand it /dev/urandom or an equivalent seed file *and actually use that* I
> don't 1000% care, but using a non-cryptographic RNG on top of that is very
> smelly.

I completely agree with you that a CSPRNG would be best. However, we
got so much pushback from the mailing list that I felt it was better
to start small. Keeping the current interface and adding an optional
better implementation underneath seems like the way to go here.

At least for our use cases, we couldn't use /dev/{u}random directly
because we needed reproducibility. However, the workflow I plan to use
with this is grab a seed from /dev/random at the beginning of the
build process, note that down somewhere, and use that seed for the
rest of the build. We could certainly do something similar with a
slightly modified RNG impl class which uses a random buffer or
separate process to generate better randomness with a larger seed.

> It also simplifies the code (since you don't need to add in a new RNG, just
> read off of a stream) and makes it more testable (since RNGs are notoriously
> easy to get wrong and hard to prove right).

Yes, as long as that stream is reproducible somehow. I think we should
preserve the option to recreate all random choices made by LLVM when
bugs crop up or for generating patches.

- Stephen



More information about the llvm-commits mailing list