Coordination: changes to PRNG libraries
curiousleo opened this issue · comments
To avoid duplication of work, let's track work we've done to make PRNG libraries compatible with the interface-to-performance
branch here.
Feel free to edit this description directly.
splitmix
: https://github.com/lehins/splitmix/tree/new-random (diff)
- implement
RandomGen
- implement
Prim
pcgen
: https://github.com/curiousleo/pcgen/tree/new-random (diff)
- implement
RandomGen
- implement
Prim
mwc-random
: WIP https://github.com/curiousleo/mwc-random/tree/random-v1.2-compat (diff)
- implement
MonadRandom
- get tests to build (depend on QuickCheck)
random-fu
: does not depend on random
; uses random-source
to abstract over concrete PRNGs
QuickCheck
: builds with StdGen
from random v1.1
on non-GHC platforms. That won't work with random v1.2
.
hedgehog
: requires instance UniformRange Integer
which is currently missing.
- builds against
random v1.2
- test suite runs against
random v1.2
: missinginstance UniformRange Integer
https://github.com/bos/mwc-random/compare/master...curiousleo:random-v1.2-compat?expand=1 fails to build with
mwc-random/System/Random/MWC.hs:414:28: error:
Multiple declarations of ‘Seed’
Declared at: System/Random/MWC.hs:389:16
System/Random/MWC.hs:414:28
|
414 | newtype Frozen (Gen s) = Seed
| ^^^^
I don't know how to fix that.
@curiousleo It is a newtype
, so you need to wrap with a constructor.
@curiousleo It is a
newtype
, so you need to wrap with a constructor.
Fixed. Thanks!
Alright gentleman, I implemented some benchmarks for all pure RNGs available in Haskell and results are pretty impressive. Here is a PR and a branch that you can use to run benchmarks for both random-1.1 and random-1.2: lehins/haskell-benchmarks#7
Here are also all the repo's with fixed RandomGen
instances:
- lehins/Xorshift#1
- lehins/mersenne-random-pure64#1
- lehins/tf-random#1
- lehins/pcg-random#1
- lehins/pcgen#1
It is pretty cool that changes were incredibly minimal and all of them are backwards compatible.
To run benchmarks:
$ cd haskell-benchmarks/new-random-benchmarks/
$ stack bench --ba '--output old-random-word16.html --match prefix Pure/Word16' --stack-yaml stack-old-random.yaml
$ stack bench --ba '--output new-random-word16.html --match prefix Pure/Word16'
And so on for other types. (It's possible to run them all at once, but I find the plots bit noisy that way)
Next in line are stateful RNGs, but those I think I'll do some time later.
Alright gentleman, I implemented some benchmarks for all pure RNGs available in Haskell and results are pretty impressive. Here is a PR and a branch that you can use to run benchmarks for both random-1.1 and random-1.2: lehins/haskell-benchmarks#7
Here are also all the repo's with fixed
RandomGen
instances:* [lehins/Xorshift#1](https://github.com/lehins/Xorshift/pull/1) * [lehins/mersenne-random-pure64#1](https://github.com/lehins/mersenne-random-pure64/pull/1) * [lehins/tf-random#1](https://github.com/lehins/tf-random/pull/1) * [lehins/pcg-random#1](https://github.com/lehins/pcg-random/pull/1) * [lehins/pcgen#1](https://github.com/lehins/pcgen/pull/1)
It is pretty cool that changes were incredibly minimal and all of them are backwards compatible.
This is fantastic!
Next in line are stateful RNGs, but those I think I'll do some time later.
I would also be interested in benchmarks for uniformRM
since we put a lot of effort into optimising the range algorithms.