When I run this program with -s
:
module Main where
import Control.Parallel.Strategies
main :: IO ()
main = do let xs = take 1000 $ product . take 1000 . repeat <$> [1..]
x = product (xs `using` parList rseq)
putStrLn (show x)
Sparks are created:
SPARKS: 1000 (993 converted, 0 overflowed, 0 dud, 6 GC'd, 1 fizzled)
If i change parList
toparTraversable
x = product (xs `using` parTraversable rseq)
no sparks are created:
SPARKS: 0 (0 converted, 0 overflow, 0 dud, 0 GC'd, 0 fizzled)
If I change rseq
to rdeepseq
:
main = do let xs = (take 1000 $ product . take 1000 . repeat <$> [1..]) :: [Integer]
x = product (xs `using` parList rdeepseq)
putStrLn (show x)
No sparks are created
SPARKS: 0 (0 converted, 0 overflow, 0 dud, 0 GC'd, 0 fizzled)
I use parallel-3.2.1.1 and in the source code parList
is defined using parTraversable
!
parList :: Strategy a -> Strategy [a]
parList = parTraversable
What am I missing?
source
share