[Haskell-cafe] Re: Strange memory usage problem
Ketil Malde
ketil at malde.org
Sat Aug 1 13:10:40 EDT 2009
John Lato <jwlato at gmail.com> writes:
> I can confirm this behavior on GHC 6.10.4 on OSX 10.5.7.
Great, thanks!
> Try adding
> {-# INLINE getRB #-}
> above the getRB definition. That fixes it for me.
And I especially appreciate this, of course. It appears to do the
trick here, too.
> I think that when the rest of the code is commented out, getRB is only
> called in one location, so GHC inlines it automatically. Since getRB
> is also called in the commented-out code, it probably isn't
> automatically inlined when that code is available. I suspect that the
> inlining allows GHC to infer some strictness property it otherwise
> can't.
Sounds reasonable. The getRB function 'get's a couple of bytestrings
and lazy bytestrings from the input - apparently these aren't fully
evaluated by the Get monad? I thought it might be the lazy ones, but
I replaced them with strict bytestrings with no noticable success.
I'm not entirely happy with the inline pragma as a solution, since it
indicates that I'm depending on the optimizing-fu of GHC to make my
program work, and this seems fragile. So far, it appears to be the
best solution.
-k
--
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe
mailing list