[Haskell-cafe] #haskell works

Dan Piponi dpiponi at gmail.com
Fri Dec 14 15:57:38 EST 2007

On Dec 14, 2007 12:12 PM, Andrew Coppin <andrewcoppin at btinternet.com> wrote:
> Today, with a few import statements and compiler switches, the
> exact same code takes 0.05 seconds. Tomorrow, who knows? Maybe I'm being
> overly optimistic, but... ;-)

There have been some great improvements in array handling recently. I
decided to have a look at the assembly language generated by some
simple array manipulation code and understand why C is at least twice
as fast as ghc 6.8.1. One the one hand it was disappointing to see
that the Haskell register allocator seems a bit inept and was loading
data into registers that should never have been spilled out of
registers in the first place. On the other hand, the code wasn't
fundamentally doing anything weird (eg. it wasn't doing graph
reductions or anything like that, it looked like the sort of loop you
might get from a C compiler). It was a few seconds of fairly mindless
work to fix up the assembly language and make it much faster. And if I
can do it, it means that the next generation of Haskell compiler
should be able to do it too, after all, good freely available methods
to allocate registers do exist. So I'm looking forward to the next
version of GHC matching C's performance for inner loops of array
manipulation code :-)

More information about the Haskell-Cafe mailing list