caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Fork-friendly GC
@ 2007-06-26 14:00 Jon Harrop
  2007-07-02 17:46 ` [Caml-list] " Tom
  0 siblings, 1 reply; 3+ messages in thread
From: Jon Harrop @ 2007-06-26 14:00 UTC (permalink / raw)
  To: caml-list


Whilst reading the ripples that resulted from our recent discussion of 
asynchonous invocation and parallelism in vanilla OCaml, someone mentioned 
the idea of "fork-friendly" garbage collectors.

I believe this refers to the coalescing of GC tags into contiguous memory. If 
so, that means that OCaml's current GC is not fork-friendly because it 
scatters tags everywhere.

Is that correct?

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
The OCaml Journal
http://www.ffconsultancy.com/products/ocaml_journal/?e


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Fork-friendly GC
  2007-06-26 14:00 Fork-friendly GC Jon Harrop
@ 2007-07-02 17:46 ` Tom
  2007-07-03  1:42   ` David Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Tom @ 2007-07-02 17:46 UTC (permalink / raw)
  To: Jon Harrop; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 884 bytes --]

Well, I believe that Fork-friendly GC is the same as Paging-friendly GC -
i.e., after a fork(), the memory is not copied into two different processes
until it is modified. So, even if a process allocates and modifies only a
small percentage of memory, the allocations might trigger the GC, which
means that all the memory is going to be swept and modified - and thus
copied.

The problem is, of course, that this is very process and/or programm
specific - it makes sense for the 24 Apache child processes to do GC, but it
is a waste of time for a forked BASH script processes that is going to
exec() after just a few lines.

The best solution I see here is to abandon the fork()-ing alltogether -
either things are run in the same process, only different threads, or
completely new processes are started (though one can only do that on Windows
platform, not on *NIX - AFAIK).

 - Tom

[-- Attachment #2: Type: text/html, Size: 916 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Fork-friendly GC
  2007-07-02 17:46 ` [Caml-list] " Tom
@ 2007-07-03  1:42   ` David Thomas
  0 siblings, 0 replies; 3+ messages in thread
From: David Thomas @ 2007-07-03  1:42 UTC (permalink / raw)
  To: caml-list

It seems to me that an incomplete but simple solution
is to stop garbage collection on the shared heaps, and
allocate new objects on fresh pages, unique to each
process.  This does, of course, mean that some objects
which should be freed don't get freed, but this seems
a price worth paying - we're only wasting some of the
memory instead of all of the memory, and we're not
taking nearly as much time.

Perhaps it's even possible to detect when we've
written to one of these pages, and re-add them to the
heap when the OS has already copied them for us, but
that's getting more complicated than necessary for a
first pass...


       
____________________________________________________________________________________
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more. 
http://mobile.yahoo.com/go?refer=1GNXIC


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-07-03  1:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-26 14:00 Fork-friendly GC Jon Harrop
2007-07-02 17:46 ` [Caml-list] " Tom
2007-07-03  1:42   ` David Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).