
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

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.

On Mon, May 7, 2012 at 7:00 AM, 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.
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

Hi, Am Montag, den 07.05.2012, 15:33 +0200 schrieb Jurriaan Hage:
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?
there is performGC: http://hackage.haskell.org/packages/archive/base/latest/doc/html/System-Mem.... Greetings, Joachim -- Joachim "nomeata" Breitner mail@joachim-breitner.de | nomeata@debian.org | GPG: 0x4743206C xmpp: nomeata@joachim-breitner.de | http://www.joachim-breitner.de/

Hi,
On Mon, May 7, 2012 at 6:33 AM, 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?
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

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-coll... 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
participants (5)
-
Christopher Done
-
Joachim Breitner
-
Johan Tibell
-
Jurriaan Hage
-
Simon Marlow