Complexity bug in garbage collector?

Josef Svenningsson josef.svenningsson at gmail.com
Fri Jul 29 07:53:28 EDT 2005

Hi,

On 7/22/05, Simon Marlow <simonmar at microsoft.com> wrote:
> On 16 April 2005 23:19, Josef Svenningsson wrote:
>
> > OK, I've cooked up this little program to study the behaviour a
> > little closer: \begin{code}
> > module Main where
> >
> > main = print $strictId [1..] > > > > strictId list = let (c,c') = work list c' > > in c > > where work [] y' = (y',[]) > > work (x:xs) y' = (v,x:v') > > where (v,v') = work xs y' > > \end{code} > > > > This program just allocates like crazy til it dies. The funny looking > > strictId function is just the strict identity function on lists. (Yes, > > there are simpler ways to achieve the same thing. I just think the > > above function is particularly sweet :-) > > > > I do the following: > >$ ghc -prof -auto-all --make Main.hs
> > \$ main.exe +RTS -hd -M<VERY MUCH>
> >
> > The resulting graph is suspiciously similar in shape to the one of my
> > previous program. The garbage collector is still my primary suspect, I
> > simply don't know how to explain the graph otherwise.
>
> I don't see a curve in the profile on my machine:
>
>
> This was on a Windows box, I also get the same results on a Linux
> machine.  I was only able to test with -M600m on the Windows box.  Do
> you need more to get the curve?
>
I used -M512M so that should be fine. But I think you should wait a
little longer before you hit ^C. When I tried it just now I waited for
a minute. It produced a curve like I reported before.
But maybe this has something to do with swapping? My machine was
definitely swapping when I aborted the program. Can that have any
effect on the timings?

Cheers,

/Josef