Re: Explicit calls to the garbage collector.

2012-05-08 Thread Simon Marlow

On 07/05/2012 14:33, Jurriaan Hage wrote:

LS.

I have a very memory intensive application. It seems that the timing of my 
application
depend very much on the precise setting of -H...M in the runtime system (-H2000M
seems to work best, computation time becomes a third of what I get when I pass 
no
-H option).  I conjecture that this good behaviour is the result of gc 
happening at the right time.
So I wondered: if I can one when is the right time, is it possible then to 
trigger
GC explicitly from within the Haskell code?


It is more likely that you are trading extra memory for better 
performance, rather than triggering the GC at a good time.  GC is 
basically a space/time tradeoff, see:


http://stackoverflow.com/questions/3171922/ghcs-rts-options-for-garbage-collection/3172704#3172704

If you think the program has points where residency is very low and it 
would be good to trigger a GC, I would first confirm the hypothesis by 
doing a heap profile.  GC can be triggered with System.Mem.performGC.


Cheers,
Simon

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Explicit calls to the garbage collector.

2012-05-07 Thread Jurriaan Hage
LS.

I have a very memory intensive application. It seems that the timing of my 
application 
depend very much on the precise setting of -H...M in the runtime system 
(-H2000M 
seems to work best, computation time becomes a third of what I get when I pass 
no
-H option).  I conjecture that this good behaviour is the result of gc 
happening at the right time.
So I wondered: if I can one when is the right time, is it possible then to 
trigger
GC explicitly from within the Haskell code? 

best,
Jur
 
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Explicit calls to the garbage collector.

2012-05-07 Thread Christopher Done
I would also be interested to know this. A web server is an example of
a Haskell program that could force garbage collection at the end of
every request reply, especially a multi-threaded server where the
memory use is localized to threads. For long-running applications, a
GC at this point would be nice.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Explicit calls to the garbage collector.

2012-05-07 Thread Johan Tibell
Hi,

On Mon, May 7, 2012 at 6:33 AM, Jurriaan Hage j.h...@uu.nl wrote:
 LS.

 I have a very memory intensive application. It seems that the timing of my 
 application
 depend very much on the precise setting of -H...M in the runtime system 
 (-H2000M
 seems to work best, computation time becomes a third of what I get when I 
 pass no
 -H option).  I conjecture that this good behaviour is the result of gc 
 happening at the right time.
 So I wondered: if I can one when is the right time, is it possible then to 
 trigger
 GC explicitly from within the Haskell code?

You have to be very careful when benchmarking programs in garbage
collected languages. If you set the nursery size high enough the GC
might never run during your benchmark, but in a real program a big
nursery might perform worse than a smaller one. For any small GC bound
benchmark you can typically get it to run much faster by setting -A to
some ridiculous high number.

-- Johan

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Explicit calls to the garbage collector.

2012-05-07 Thread Johan Tibell
On Mon, May 7, 2012 at 7:00 AM, Christopher Done
chrisd...@googlemail.com wrote:
 I would also be interested to know this. A web server is an example of
 a Haskell program that could force garbage collection at the end of
 every request reply, especially a multi-threaded server where the
 memory use is localized to threads. For long-running applications, a
 GC at this point would be nice.

In non-GCed language people often use an arena allocator in situations
like this. However, a semi-space collector (which is what we use) we
get that behavior for free. If your request is processed in less time
than the minor GC cycle, all your data will be dead by the time the GC
run and thus collecting it is free.

-- Johan

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users