Library-vs-local performance

Don Stewart dons at
Tue Jun 24 17:01:58 EDT 2008

>      That said, it's entirely possible to program libraries in a way to
>      specifically allow full inlining of the libraries. The Data.Binary and
>      Data.Array.Vector libraries are written in this style for example,
>      which means lots of {-# INLINE #-} pragmas, maximum unfolding and high
>      optimisation levels.
>      -- Don
>    Every function has an inline pragma. Adding -O2
>    -funfolding-use-threshold999 -funfolding-creation-threshold999 does not
>    significantly change the produced .hi files (--show-iface produces roughly
>    the same files, just different headers)  This makes sense to me because
>    the library doesn't actually _do_ anything. There are no significant
>    compiled functions, everything should be inlined. And since the .hi files
>    are the same, I don't see why they wouldn't be. The two scenarios are
>    these:
>    1) Library is installed via cabal.
>    2) Library source lives in the same directory as the application, so that
>    ghc --make Examples.hs also builds the library.

That's compiling Examples with full access to the source though!
So ghc has the entire source available. Once you've installed the
library, however, only what is exposed via the .hi files can be used
for optimisation purposes. So *something* is not being inlined fully (or
some other optimisation is interferring)

Boiling this down to the smallest test case you can would be *really* 

>    When compiling the application I set all knobs to 11. In case 1,
>    ./Examples 3000000 runs in 6.9s, case 2 in 5.2s. The module structure is
>    the same in both cases, so I don't know what inlining across module
>    boundaries has to do with it.

>    By the way, the library is now on hackage,
>    [1]
>    but the documentation does not show up. What do I have to do to make this
>    happen?

Oh assuming haddock can process it, it'll appear in a few hours. Hadock
is run periodically.

More information about the Glasgow-haskell-users mailing list