Subject: bug#38753: 27.0.60; cl--random-state uncontrolled growth due to bignums

From: Pip Cet <[email-masked]>
Date: Sun, 29 Dec 2019 17:33:59 +0000

On Sun, Dec 29, 2019 at 2:27 PM Christopher Wellons
<[email-masked]> wrote:
> > Any idea how easy it would be to fix either of them, or both?
> The reason I found that bug is because I was experimenting with
> addressing exactly that problem:
>
> https://github.com/skeeto/lcg128
>
> It's got the right features, including support for arbitrary limits (per
> your example), but I'm not satisfied with the performance.

That looks excellent. Maybe we should be using a cryptographic RNG by
default, though? I really don't know the tradeoffs, though.

At first glance, there are two questions I have about lcg128:
 - should random floats have more than 53 significant bits if they're
< 0.5? I think the answer is yes, even though that will make the
implementation harder.
 - should (lcg128-range 2^n) call the generator twice, on average? I
think it's an important special case in which we only want to call the
generator once.