[Haskell-cafe] Performance Help

David Brown haskell2 at davidb.org
Fri Mar 16 17:29:36 EDT 2007

Ian Lynagh wrote:
> On Sun, Mar 11, 2007 at 08:18:44PM +0000, Dominic Steinitz wrote:
>> I have re-written the sha1 code so that it is (hopefully) easy to see
that it
>> faithfully implements the algorithm (see
>> http://www.itl.nist.gov/fipspubs/fip180-1.htm). Having got rid of the
>> leak, I have been trying to improve performance.
>> Currently, the haskell code is 2 orders of magnitude slower than the
>> that ships with my linux.
> I don't know if this is useful to you, but darcs has some SHA1 code that
> IIRC is much closer to C's performance. It currently uses darcs' own
> FastPackedString library, but porting it to ByteString should be fairly
> easy.
> See SHA1.lhs in http://www.abridgegame.org/repos/darcs-unstable
> It might even be able to be made faster still by calling lower-level
> functions than {shift,rotate}{L,R} directly.

I ended up deciding to call SHA1 routines out of openssl.  For
applications where this is possible, it does very well, I got about
2.5 times the speed out of it, compared to ordinary C implementations.

But, since harchive spends most of its CPU computing SHA1 hashes (and
almost all of the rest in zlib), it is worth a complex binding there.


More information about the Haskell-Cafe mailing list