Transitioning to a type aware Garbage Collector

Sean Kelly sean at f4.ca
Tue Jan 23 13:28:01 PST 2007


Pragma wrote:
> Sean Kelly wrote:
>> Paul Findlay wrote:
>>> Walter Bright wrote:
>>>> To improve GC performance, we need to transition to a GC that is 
>>>> aware of the types of what it is allocating.
>>> Does this mean the D garbage collector will be an exact (or precise) 
>>> garbage collector?
>>
>> If a block contains pointers then the entire block will still be 
>> scanned instead of just the pointers in that block, so It will still 
>> be a conservative collector but with fewer false positives.  I think 
>> this could be changed so that just the pointers were scanned, but 
>> there would likely be a noticeable performance hit for doing so. 
> 
> I was going to say: it sounds an awful lot like Walter is going to have 
> the GC  stamp each allocated block (or its corresponding record) with a 
> field that amounts to "bool containsPointers".  I'm all for it.  

That's basically it.  The Tango GC already works this way, but it keys 
off of element size for arrays or block size for non-arrays.  Walter's 
will be using TypeInfo to determine whether the block contains any 
pointers, so it will be far more accurate.  I imagine a situation could 
be contrived whereby struct or class data could cause false positives, 
but I don't expect it to be much of an issue in practice.

> Especially since the majority of allocations and re-allocations in a 
> typical D program are for strings, images and other non-pointer related 
> data.  This simple change will amount to much smaller GC pauses, 
> especially in the video games department.

Yup.  This was the original motivation for the changes in Tango.  I 
figured that by simply eliminating char strings from scanning, things 
would improve significantly.  And they pretty much have.

>  > If false positives
>  > are still a concern (and I'm not convinced they will be), a better
>  > approach may be to pursue a different GC design such as the CBGC
>  > mentioned yesterday.
> 
> I haven't had a chance to read the paper myself, but the abstract left 
> me with the impression that it's a good middle-of-the road approach to 
> things.
> 
> Just an aside here: I keep reading that as "CBGB".

Me too :-)


Sean



More information about the Digitalmars-d-announce mailing list