On Mon, Jun 18, 2007 at 11:55:05AM +1000, Thomas Conway wrote:
> Hi All,
> 
> I'm trying to figure out how to maximum performance out of one of my
> inner loops which involves string hashing.
> 
> Consider the following hash function, which is a transliteration of a
> good one written in C:
[ Code elided ]
> Obviously, we'd like all those lambdas and composes to be inlined,
> along with all the intermediate Triple structures. So, how do you
> convince ghc to do this? Alternatively, how would you *translate*
> rather than transliterate, the mix function?

Just pass the -O option to GHC. (-O2 for better results).  On my system
there are no lambdas or (.) left, as confirmed with -ddump-simpl.

However, GHC's 64 bit type is implemented using full foreign calls (and
thus rather expensive...) on 32 bit systems!  So if possible don't do
that.

Also, GHC produces this type signature for $wmix:

HashStr.$wmix :: GHC.Word.Word64
                 -> GHC.Prim.Word64#
                 -> GHC.Prim.Word64#
                 -> HashStr.Triple

That is, the unboxing is incomplete.  This is very very fishy; I'm
submitting a bug.

Stefan
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to