www.digitalmars.com         C & C++   DMDScript  

D - helping out the GC

reply "Ben Hinkle" <bhinkle4 juno.com> writes:
Thinking more about GC performance, what do people
think about adding some features to help it out?
I'm thinking of "hints" that the programmer can
put in D code to give the GC more information about
what is going on. For example, assuming a generational
GC will eventually be used in phobos, it would
help out the GC to tell it if an object should
immediately go into an old generation - many times
I know when something will hang around for a while
or if something is just going to be used for a few
calls and then be gone. Or maybe a way to mark an
object as garbage as soon as all stack/register
references to it are gone. Maybe with custom allocators
no language changes would be needed - I don't know.

Also putting in a hook after gc_init to allow main()
to set various GC parameters (before actually allocating
anything) would be nice. For example Sun's Java GC
implementation has command-line switches for customizing
the GC behavior.

I'm not a GC expert by any means but I've used Java
extensively and I know how important it is to be
aware of memory management even with GC - at least
for large scale programs.

Or if people know about links to "user driven" GC that
would be nice, too.

-Ben
Feb 29 2004
next sibling parent Cloud9 Virtual <cloud9virtual yahoo.com> writes:
Ben Hinkle wrote:
 
 Or if people know about links to "user driven" GC that
 would be nice, too.
 
I have been looking into this as I am interested in a real time garbage collector; Unfortunately all the newer research on this topic is proprietary, patent-pending etc. You may want to get this book: http://www.amazon.com/exec/obidos/tg/detail/-/0471941484/qid=1078171665/sr=1-8/ref=sr_1_8/102-8829146-1694527?v=glance&s=books It's the only book I know that summarises the publicly available GC tech. to date. I also have links to various research papers; each GC strategy in existance can be the best performer depending on program allocation patterns (even the classical mark/sweep implemented currently in D). What researchers do now is experiment with dinamically switching the GC strategy at runtime. The research tool of choice is the Jikes JVM.
Mar 01 2004
prev sibling parent "=?iso-8859-1?Q?Robert_M._M=FCnch?=" <robert.muench robertmuench.de> writes:
On Sun, 29 Feb 2004 17:38:14 -0500, Ben Hinkle <bhinkle4 juno.com> wrote:

 Thinking more about GC performance, what do people
 think about adding some features to help it out?
Hi, I'm reaching the point in my Dernel kernel, where I want to get the GC stuff up and running. At the moment, the interface works but I use a stupid "just allocate" strategy with no-frees at all ;-). So we can play around with this.
 I'm thinking of "hints" that the programmer can
 put in D code to give the GC more information about
 what is going on. For example, assuming a generational
 GC will eventually be used in phobos, it would
 help out the GC to tell it if an object should
 immediately go into an old generation - many times
 I know when something will hang around for a while
 or if something is just going to be used for a few
 calls and then be gone.
I used to use memory-pools in C++. IMO if we can tell the GC, to setup pools for specific classes/structs and provide an estimated life-time, this could help selecting the best allocation strategy. One other way would be to use templates for specialized GC implementations. In this case, you would instantiate exactly the best set of functions for your app. The GC would become spezialized for each app. I once came across a GC framework based on templates for C++. I need to have a look, if I still have this information.
 Also putting in a hook after gc_init to allow main()
 to set various GC parameters (before actually allocating
 anything) would be nice. For example Sun's Java GC
 implementation has command-line switches for customizing
 the GC behavior.
I like the template approach most. With run-time configuration you always have to carry around the complete code to handle everything. But the GC should become a highly specialized implementation fitting the current app.
 Or if people know about links to "user driven" GC that
 would be nice, too.
There is a GC project called "frankestein": http://www.cs.washington.edu/homes/pardy/research/gc/ I'm highly interested in this topic WRT Dernel. Understanding the GC code etc. is a necessary step, so any help is welcome :-)) -- Robert M. Münch Management & IT Freelancer http://www.robertmuench.de
Mar 02 2004