#427: Random.StdGen slowness
---------------------------------+------------------------------------------
Reporter: remit | Owner:
Type: bug | Status: new
Priority: low | Milestone: _|_
Component: libraries/random | Version:
Severity: normal | Resolution: None
Keywords: | Difficulty: Unknown
Testcase: | Os: Unknown/Multiple
Architecture: Unknown/Multiple |
---------------------------------+------------------------------------------
Comment (by Remi):
Replying to [comment:16 dons]:
> http://galois.com/~dons/tmp/seq-strict-random.dpatch
>
> Needs someone to test it now :-)
I haven't done any benchmarking, but it doesn't fix the thunk-bomb:
All getStdRandom does is call atomicModifyIORef, and when its result is
not forced, that'll just atomically store a thunk... Perhaps it's time for
atomicModifyIORef'? (That is, strict but still both atomic and fast.)
What does work for the thunk-bomb problem is simply
{{{
- getStdRandom f = atomicModifyIORef theStdGen (swap . f)
+ getStdRandom f = atomicModifyIORef theStdGen (swap . f) >>= (return $!)
}}}
That won't make it faster though.
By the way, is anyone else interested in getting the current Random
redesigned?
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/427#comment:17>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs