You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, first thanks for that small code, it's interesting!
I'm trying to solve this with it, for the fun of it.
Now regarding the sync.Pool, I'm not sure this is so much per CPU than it is per goroutine.
If you have 1000 goroutines at the same time, there will be 1000 RNG objects (well just 1000x 1 uint32 really so that's fine memory wise).
Indeed if you have 4 CPU intensive goroutines on a 4 core CPU, there will be one RNG per core but that's a particular case.
Should we mention that in the readme?
There is also another problem: if you launch 1000 goroutines at start, it 'could' create 1000 RNG initialized with the same time (unlikely, but it can happen on certain systems with bad time resolution) and that can lead to a quite bad pseudo randomness.
Maybe a solution would be to use crypto/rand the first time when creating the RNG object via the sync.Pool's New field function?
The text was updated successfully, but these errors were encountered:
Hello, first thanks for that small code, it's interesting!
I'm trying to solve this with it, for the fun of it.
Now regarding the
sync.Pool
, I'm not sure this is so much per CPU than it is per goroutine.If you have 1000 goroutines at the same time, there will be 1000 RNG objects (well just 1000x 1 uint32 really so that's fine memory wise).
Indeed if you have 4 CPU intensive goroutines on a 4 core CPU, there will be one RNG per core but that's a particular case.
Should we mention that in the readme?
There is also another problem: if you launch 1000 goroutines at start, it 'could' create 1000 RNG initialized with the same time (unlikely, but it can happen on certain systems with bad time resolution) and that can lead to a quite bad pseudo randomness.
Maybe a solution would be to use
crypto/rand
the first time when creating theRNG
object via the sync.Pool'sNew
field function?The text was updated successfully, but these errors were encountered: