Library-vs-local performance

Don Stewart dons at
Tue Jun 24 18:15:53 EDT 2008

>    On Tue, Jun 24, 2008 at 3:51 PM, Don Stewart <[1]dons at> wrote:
>      >
>      >    I've taken all optimization flags out of the .cabal file. They
>      don't have
>      >    any effect. My understanding of things is this: (please correct if
>      wrong)
>      >    All functions have inline pragmas, and all are small (1 or 2 lines)
>      so
>      >    their definitions are all spewed into the .hi files. So in both
>      scenarios
>      >    (library vs local) GHC can "see" the whole library. Since every
>      function
>      >    is inlined, it doesn't matter what flags the library is compiled
>      with.
>      >    That compiled code will never be used so long as the application is
>      >    compiled with optimization on.
>      You might want to give the simplifier enough time to unwind things.
>      I use, e.g.
>                 -O2
>                 -fvia-C -optc-O2
>                 -fdicts-cheap
>                 -fno-method-sharing
>                 -fmax-simplifier-iterations10
>                 -fliberate-case-threshold100
>      in my ghc-options for 'whole program' libraries.
>      Raise these limits if you find they're having an effect
>      -- Don
>    Yeah I saw those in your uvector library and was going to ask: what do
>    they do? Are they documented anywhere? I can't find any info on them.
>    Speicifcally, what is the case liberation threshold? (Can't even find that
>    on google.) That sounds germane because the function in question is one of
>    the few with branches.
>    And what effect does -fvia-C -optc-O2 have? Those refer to the generation
>    of machine code, do they not? If the library is essentially a core-only
>    library, why use them? As far as I can tell, even -O2 is ineffectual when
>    compiling the library. 'Compiling' here is even a misnomer. We're just
>    transliterating from haskell to core.

Nope, there's a lot of optimisations taking place on the core-to-core
phase, to ensure the core that gets unfolded into your .hi files is as
nice as possible. And then still there's things that actually stay as
calls into your compiled library -- for those, you'll want direct jumps
and so forth, which you get with -fvia-C -optc-O2 and above.

See my recent post on micro optimisations.

-- Don

More information about the Glasgow-haskell-users mailing list