3 ms·
Random Number Generation for the cost of a copy
- cperciva 18y agoEven if you pretend that you always have a free core available for precomputing a stream of random numbers, accessing them is more expensive than a copy -- you need to have locking in place to make sure that you don't give two people the same random numbers. (You could pregenerate per-CPU pools of random numbers, but then you have a different synchronization problem: You need to make sure that you don't migrate to a different CPU between looking up which CPU you're on and reading the random numbers.)
- tptacek 18y agoI don't get it. Isn't this exactly what every operating system already does to feed random numbers to userland? Is this just a reinvention of entropy pools? I'm pretty sure this is why the OS provides both a blocking and a non-blocking interface to getting random numbers. Also, consider that if it's taking a long time to compute random numbers, that might be because you're doing it insecurely.