[Haskell-cafe] Control.Parallel seemingly randomly behaviour

David Feuer david.feuer at gmail.com
Tue Jan 17 00:01:20 UTC 2017


Just to remove one variable: what happens if you run the same executable
multiple times, rather than rebuilding it each time?

On Jan 15, 2017 6:34 PM, "Juan Luis Martty" <jmartty at hotmail.com> wrote:

Hello everyone,

I'm having a consistency issue with the following piece of code:

heavyAm = 500
lightAm = 1000

heavyCalc :: Int -> Int
heavyCalc s = sum [1..1000000*s]

parallel = (heavyCalc lightAm, heavyCalc heavyAm) `using` (parTuple2 rseq
rseq)

For some reason, during runtime the RTS sometimes parallelizes the
evaluation and sometimes it doesn't. I'm running with all the RTS/compile
time options correctly afaik. Here is the output from a couple of runs of
the program:

jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe
Warning: File listed in par.cabal file does not exist: README.md
(500000000500000000,125000000250000000)
Computation time: 1.557007s

real    0m1.732s
user    0m2.528s
sys 0m0.464s
jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe
Warning: File listed in par.cabal file does not exist: README.md
(500000000500000000,125000000250000000)
Computation time: 1.544837s

real    0m1.720s
user    0m2.544s
sys 0m0.712s
jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe
Warning: File listed in par.cabal file does not exist: README.md
(500000000500000000,125000000250000000)
Computation time: 2.316537s

real    0m2.484s
user    0m2.592s
sys 0m0.680s
jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe
Warning: File listed in par.cabal file does not exist: README.md
(500000000500000000,125000000250000000)
Computation time: 2.318514s

real    0m2.489s
user    0m2.612s
sys 0m0.688s
jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe
Warning: File listed in par.cabal file does not exist: README.md
(500000000500000000,125000000250000000)
Computation time: 1.544975s

real    0m1.718s
user    0m2.512s
sys 0m0.456s

As you can see, sometimes wall time roughly equals userspace time,
sometimes it doesn't (meaning it parallelized at least some amount). I'm
running on a dual core machine under Ubuntu using stack with lts-7.14 (GHC
8.0.1) and parallel-3.2.1.0.

Regards,
Juan


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170116/fd66b57b/attachment.html>


More information about the Haskell-Cafe mailing list