[Haskell-cafe] Question about memory usage

Jason Dagit dagit at codersbase.com
Mon Aug 16 18:33:12 EDT 2010


On Mon, Aug 16, 2010 at 9:00 AM, Sebastian Fischer <
sebf at informatik.uni-kiel.de> wrote:

> [CC-ing café again]
>
>
> On Aug 16, 2010, at 5:52 PM, Daniel Fischer wrote:
>
>  I am a bit concerned about the memory usage.
>>>
>>
>> Of your implementation of the matrix power algorithm?
>>
>
> Yes.
>
>  Making the fields of Matrix strict should help:
>>
>> data Matrix a = Matrix !a !a !a
>>
>
>
> Making all fields strict makes memory usage worse. When making only the
> first field strict, memory usage hardly differs (from the current
> implementation without strictness annotations).


That's interesting.  So next I would use heap profiling to find out where
and what type of data the calculation is using.  I would do heap profiling
and look at the types.  The strictness above should when there are lots of
thunks in memory for computing the values in the Matrix.

To get started at this task, I recommend the chapter on performance from
Real-World Haskell:
http://book.realworldhaskell.org/read/profiling-and-optimization.html

I'd love to hear what you learn as I probably won't have time to poke at it.

Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100816/23caab9b/attachment.html


More information about the Haskell-Cafe mailing list