[Haskell-cafe] g++ std:map vs GHC IntMap

Jon Harrop jon at ffconsultancy.com
Sat Apr 4 06:42:37 EDT 2009

On Thursday 26 March 2009 15:39:12 Manlio Perillo wrote:
> I also tried with Data.HashTable:
> http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2902
> but memory usage is 703 MB, and execution time is about 4.5 times slower!

This is due to a perf bug in GHC's GC implementation that causes it to 
traverse entire arrays when a single element has been changed. Hence the 
Haskell is over an order of magnitude slower than most languages and even 
slower than Python (!).

The purely functional trees that you also used are apparently the idiomatic 
Haskell workaround but, of course, they are extremely inefficient and still 
over an order of magnitude slower than any decent hash table.

For comparison:

Haskell hash table: 44s
Haskell map:         7s
F# hash table:       0.7s

Dr Jon Harrop, Flying Frog Consultancy Ltd.

More information about the Haskell-Cafe mailing list