garbage collection

Simon Marlow simonmar at microsoft.com
Tue Apr 19 08:15:53 EDT 2005


On 12 April 2005 15:59, Bulat Ziganshin wrote:

> Hello glasgow-haskell-users,
> 
> 1) can you add disableGC and enableGC procedures? this can
> significantly improve performance in some cases

Sure.  I imagine you want to do this to avoid a major collection right
at the peak of a residency spike.

You probably only want to disable major collections though: it's safe
for minor collections to happen.

You might be better off using System.Mem.performGC just before the
residency spike.  This doesn't have the pitfalls of enable/disableGC,
but it might entail doing more GC than necessary.

> 2) if, for example, program's data before GC is 80 mb and after GC is
> 60 mb then the program will occupy after GC the whole 140 mb and ALL
> this space will be marked by OS as used! if there's a memory shortage,
> old program data even can be swapped to disk despite the fact that we
> absolutely don't need them! that behaviour significantly enlarge
> memory needs of GHC-compiled programs
> 
> if this unused memory will be returned to OS or marked as unneeded
> after GC then will problem will go on. preferably this must be done
> during the time of GC, on each page which contents has been already
> compacted. in this case such program will never use more than 80mb of
> real memory (+ 1 page + memory for GC)

I guess you're proposing using madvise(M_FREE) (or whatever the
equivalent is on your favourite OS).  This would certainly be a good
idea if the program is swapping, but might impose an overhead when
running in memory.  I don't know, I haven't tried.

Also, you might be better off using +RTS -c or +RTS -M<size> to avoid
swapping in the first place.

Cheers,
	Simon


More information about the Glasgow-haskell-users mailing list