[Haskell-cafe] sha1 implementation thats "only" 12 times slower then C

Alistair Bayley alistair at abayley.org
Tue Jul 3 17:40:32 EDT 2007


On 03/07/07, Anatoly Yakovenko <aeyakovenko at gmail.com> wrote:
> inlining some of the functions definitely gave me a boost, so i am
> about 8.5 times slower then openssl sha1sum.  I dont really understand
> the core output, but after inlining i got a completely different
> profile output, i am guessing its because the cost of the inlined
> functions is spread to the callers.

Are you using -auto, or -auto-all? Because it makes a difference to
the generated core, and the extent to which inlining takes place. I've
noticed that -auto permits more inlining than -auto-all, so try -auto
if you can. Also, follow the advice in the GHC manual, and only export
the functions you need to. This will aid both the inliner and
specialiser enormously.

As for reading core (well, actually simplifier output; core has less
"punctuation"), these links might help:

4.16.3. How to read Core syntax
http://www.haskell.org/ghc/docs/latest/html/users_guide/options-debugging.html#id3130643

(and the Encoding module has the actual rules for the Unique names)
http://darcs.haskell.org/ghc/compiler/utils/Encoding.hs

6.2. Faster: producing a program that runs quicker
http://www.haskell.org/ghc/docs/latest/html/users_guide/faster.html
(see "How do I find out a function's strictness?")

Alistair


More information about the Haskell-Cafe mailing list