[Icfp04-discuss] Re: haskell simulator performance

Tomasz Zielonka t.zielonka at zodiac.mimuw.edu.pl
Fri Jun 11 10:24:19 EDT 2004


On Wed, Jun 09, 2004 at 05:21:08PM -0700, David Brown wrote:
> On Wed, Jun 09, 2004 at 12:07:36PM +1000, Ben Lippmeier wrote:
> 
> > What structure did you store the terrain in? After several false starts 
> > with one or other of the umteen different kinds of Haskell arrays, I 
> > ended up copping out and storing the whole lot in C land, using foreign 
> > ccalls to access it from the IO monad.
> 
> I used an IOARRAY (Int, Int) Cell
> data Cell
>   = Rocky
>   | Clear {
>      cellFood    :: Int,
>      cellMarkers :: Markers
>      cellHill    :: Maybe Color
>   }
> 
> where the index was (y, x).  Not the best performance, but not too bad.

I did almost the same but my simulator managed to process only 200
rounds per second on PIII 850. Yesterday I spend some time trying to
improve things and I managed to squeeze more than 1000 RPS from it. What
I did was getting rid of most boxed arrays. I've had to "manually" unbox
some of them. But still, this is much slower than the fastest
implementations.

It seems the costs of GC write barrier and pointer chasing were quite
high, but I'm not sure which one was the biggest. Also I remember one of
GHC Simons saying that array performance in GHC is not as good as it
could be. Maybe it would be a good idea to work on this before the next
contest? It would also be nice to be able to derive unboxability for
user-defined types. I think I'll try to do something myself.

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links


More information about the Icfp04-discuss mailing list