[Haskell-cafe] Memory Management and Lists

Robin Palotai palotai.robin at gmail.com
Thu Jul 14 07:45:33 UTC 2016


For deepseq also see the"Once trick". I'm surprised it's not quoted more
often. In fact our would make sense to mention it in the deepseq docs.

On Wed, Jul 13, 2016, 21:32 David Feuer <david.feuer at gmail.com> wrote:

> You have to be careful with deepseq. Using it in the wrong place can
> lead to very bad performance. It's a big hammer. Its blow can
> sometimes be softened using the NF type from the nf package, but it's
> really not the right thing most of the time.
>
> On Tue, Jul 12, 2016 at 11:56 PM, William Yager <will.yager at gmail.com>
> wrote:
> > You probably want Control.DeepSeq. No extraneous work doing addition that
> > way either.
> >
> > Will
> >
> > On Tue, Jul 12, 2016 at 11:28 PM, Christopher Howard <ch.howard at zoho.com
> >
> > wrote:
> >>
> >> After pondering this problem some more, I found a solution to the
> >> problem was to introduce strictness, not deep down in the StateReader
> >> monad, but rather at the top level, i.e., forcing evaluation of each
> >> Matrix as soon as it is pulled of the list of Matrices. I found I could
> >> do this simply by summing all the elements in each matrix and printing
> >> the sum to std out. With this approach, i successfully run the full
> >> program and never even saw my memory performance graph move up.
> >>
> >> I suppose there might be a way to do the same thing more efficiently
> >> with seq...?
> >>
> >> On 07/12/2016 06:39 PM, Christopher Howard wrote:
> >> > I guess I was hesitating on posting the entire program source code in
> an
> >> > cafe email. I suppose I could send you a tarball, if you really wanted
> >> > it...
> >> >
> >> > Matrix is from Data.Matrix
> >> >
> >> > <
> http://hackage.haskell.org/package/matrix-0.3.5.0/docs/Data-Matrix.html>.
> >> >
> >> > It is hard to understand how thunks alone would explain it... there
> >> > would be at most 2000 thunks, right? Unless... Could there be a thunk
> >> > for every single call to getElem? That would be a lot of thunks!
> >> >
> >> > Somebody suggested adding some strictness here... could you elaborate
> on
> >> > that? I tried inserting seq, but I didn't really understand how I was
> >> > supposed to use it...
> >> >
> >>
> >> --
> >> http://qlfiles.net
> >> To protect my privacy, please use PGP encryption. It's free and easy
> >> to use! My public key ID is 0x340EA95A (pgp.mit.edu).
> >>
> >> _______________________________________________
> >> Haskell-Cafe mailing list
> >> To (un)subscribe, modify options or view archives go to:
> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> >> Only members subscribed via the mailman list are allowed to post.
> >
> >
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > To (un)subscribe, modify options or view archives go to:
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> > Only members subscribed via the mailman list are allowed to post.
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160714/e68996ec/attachment.html>


More information about the Haskell-Cafe mailing list