[Haskell-cafe] Re: MD5 performance optimizations, and GHC -via-C producing segfaulting binary

Don Stewart dons at galois.com
Tue May 20 16:36:12 EDT 2008


isaacdupree:
> Don Stewart wrote:
> >I'm confused. GHC of course unboxes strict fields of 
> >primitive data types.
> >
> >    {-# OPTIONS -O2 -fvia-C -optc-O2 -funbox-strict-fields 
> >    #-}
> 
> ... but only when you give -funbox-strict-fields, as there, 
> or UNPACK. The point is that it never loses sharing to unbox 
> a strict Int field [1], so it should do that with -O, even 
> without either of the above overrides.
> 
> [1] I'm not sure if this is true... if it has to rebox the 
> Int, you get another copy floating around, not the original, 
> right?

See section 8.12.10. UNPACK pragma:

    "if the T constructor is scrutinised and the floats passed to a
    non-strict function for example, they will have to be reboxed"

That said, the strictness analyser is beefy enough, and strict data
structures  commone enough, that this seems to almost ubiquitously be a
win.

Enabling it at -O or -O2 makes perfect sense.

-- Don


More information about the Haskell-Cafe mailing list