This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Release RTL bodies after compilation (sometimes)


On Wed, Sep 15, 2004 at 11:10:14AM -0400, Diego Novillo wrote:
> On Wed, 2004-09-15 at 08:53, Daniel Jacobowitz wrote:
> 
> > But this part, that you and Jeff keep reiterating, doesn't make sense.
> > Even with an improved garbage collector well beyond what we have today,
> > the fact is that collection is expensive, and the locality penalty for
> > garbage is expensive.
> >
> That is a symptom that GC may not be suited to our allocation profile. 
> Or that we have a bad collector.  Or any number of other mismatches.
> 
> > what's the problem with using ggc_free?
> >
> If you are going to use a garbage collector, then use a garbage
> collector.  If you find yourself having to baby sit its decisions, then
> you have a fundamental design problem.
> 
> Garbage collected memory is by definition "allocate and forget" not
> "allocate and I will tell you what to release".  If you do that, you are
> subverting the very principle of garbage collected memory.  At that
> point, you have to switch to a different memory allocation strategy,
> improve your collector, use different pools, whatever.

I hope my point is clear by now, but I'll try to summarize, since I
have the feeling I'm not getting through...

I don't think your "definition" is correct, or that marking objects as
explicitly free conflicts with the design of using a garbage collector.

Why should your memory management subsystem have to know about
everything that has a fixed lifetime?  I think that a good way to use
garbage collection, if you're willing to define its interfaces
this way, is:

  - If I know I am done with X, and no one else should be holding on to
    X, tell the GC subsystem so.  Let it decide whether to drop X back
    in the allocation pool, or hang on to X and check my assertion, or
    look at X and laugh itself silly.

  - If I think I am done with X, but I'm not statically sure, just let
    it go instead of inventing mechanisms to track it more precisely.
    The GC maid will sweep the floors for me later anyway.

No matter how much we improve the garbage collector, I think that it
will continue to be useful to have these hints.  Maybe with a
generational collector (for example) collection would be enough faster
that the right thing to do would be to ignore the hints.  Maybe it
wouldn't.  And the assertions will remain valuable.

-- 
Daniel Jacobowitz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]