address scaling issues
kaworu opened this issue · 0 comments
kaworu commented
Problem description
Currently, fake is using Go's math/rand global methods as PRNG. The global rand methods uses the single (private) globalRand generator which is based on a locked source. This approach doesn't allow multiple goroutine to use fake in a way that scales, because we end up with lock contention on globalRand's RNG source.
Proposed solution
To address this issue, fake could expose an API allowing instantiation of fake generators, e.g.
f := fake.New()
flow := f.Flow()
Each instance would have their own independent PRNG instance. Of course, this would be in addition to the current global API which is more convenient when concurrency is not needed.