[Haskell-cafe] Re: A problem with par and modules boundaries...

Mario Blažević mblazevic at stilo.com
Sun May 24 12:48:19 EDT 2009


> I recommend using -ddump-simpl, as it produces more readable output.
> 
>> Actually, I can't see any effect of that pragma in the
>> core files whatsoever, but it certainly has effect on
>> run time.
> 
> How about diffing the whole core output (and using -ddump-simpl). If
> there's a performance difference then there must be a difference in the
> core code too.

Ok.

$ ghc-6.11.20090421 --make primes-test.hs -threaded -O2 -ddump-simpl &> main.simpl
$ time ./primes-test +RTS -N2
4001

real	0m9.636s
user	0m18.201s
sys	0m0.088s

$ ghc-6.11.20090421 --make primes-test.hs -threaded -O2 -ddump-simpl &>
imported.simpl
$ time ./primes-test +RTS -N24001

real	0m17.547s
user	0m17.453s
sys	0m0.052s


I can't exactly use diff because the generated identifier names are not the same,
but after poring over with Emacs ediff I have found only one difference that's
not attributable to identifiers:

$diff main.simpl imported.simpl
...
223c232
<       a_s1rs [ALWAYS Just L] :: GHC.Integer.Internals.Integer
---
>       a_s1sV [ALWAYS Just S] :: GHC.Integer.Internals.Integer
...


Does this S vs. L difference have anything to do with strictness and laziness?
That line is a part of the `Main.test' definition:

$ diff -C 3 main.simpl imported.simpl
*** 217,244 ****
  [Arity 2
   Str: DmdType LL]
  Main.test =
!   \ (n1_ahR :: GHC.Integer.Internals.Integer)
!     (n2_ahT :: GHC.Integer.Internals.Integer) ->
      let {
!       a_s1rs [ALWAYS Just L] :: GHC.Integer.Internals.Integer
        LclId
        [Str: DmdType]
!       a_s1rs =
          Data.List.prod1
            (Main.factors2
               (Data.List.prod1
!                 (GHC.Num.up_list Main.lvl Main.lvl n1_ahR) Data.List.lvl1))
            Data.List.lvl1 } in
!     case GHC.Prim.par# @ GHC.Integer.Internals.Integer a_s1rs
      of _ { __DEFAULT ->
      case Data.List.prod1
             (Main.factors2
                (Data.List.prod1
!                  (GHC.Num.up_list Main.lvl Main.lvl n2_ahT) Data.List.lvl1))
             Data.List.lvl1
!     of x1_aUS { __DEFAULT ->
!     case GHC.Real.$wdivMod x1_aUS a_s1rs of _ { (# ww1_aUo, _ #) ->
!     ww1_aUo
      }
      }
      }


>> Or do you mean to say that *your* installation of GHC
>> behaves the same when the function `parallelize' is defined in
>> the same module and when it's imported?
> 
> Yes, exactly. With both ghc-6.10.1 and a very recent build of ghc-6.11

As you can see, I'm using the 6.11.20090421 build. I looked at recent ones, but
the Linux builds seem to be less stable in May. I have the same results (though I
didn't use -ddump-simpl) with 6.8.2. Can you recommend a different version to try?




More information about the Haskell-Cafe mailing list