[Haskell-cafe] Understanding GHC allocations

Roman Cheplyaka roma at ro-che.info
Thu Jun 17 05:40:59 EDT 2010

I'm trying to optimize the following program:

Of course general suggestions are welcome (BTW I'm going to give a try
to vector), but currently I'm concerned with two questions:

1. Heavy allocations in 'distance' function. Here is (part of) the profile:

COST CENTRE   MODULE    %time %alloc  ticks     bytes

d2            Main        9.0   22.0    290 600000000
d             Main        8.6   65.9    278 1800000000
d1            Main        7.5   11.0    242 299700000

>From reading core I got the impression that everything is strict &
unboxed. Perhaps this is related to creating some closures? How to get
rid of those allocations?

2. Again from reading the core I learned that although 'l' and other
constants are inlined, their type is boxed Double. This makes sense
since CAFs are evaluated on demand, but obviously in this particular
case it does not make sense, so can I somehow make them unboxed?

Roman I. Cheplyaka :: http://ro-che.info/
"Don't let school get in the way of your education." - Mark Twain

More information about the Haskell-Cafe mailing list