More radical ideas about gc and reference counting

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun May 11 13:33:04 PDT 2014


On 5/11/2014 2:48 AM, Benjamin Thaut wrote:
> Mostly percise doesn't help. Its either fully percise or beeing stuck with a
> impercise mark & sweep.

This is not correct. It helps because most of the false pointers will be in the 
heap, and the heap will be accurately scanned, nearly eliminating false 
references to garbage.


> Also D's GC doesn't use RTInfo currently.

Yes, but that is not an issue with the language design.


> Additionally Rainer Schuetzes implementation showed that using RTInfo with the current GC
> makes the collection actually slower at the price of beeing 'mostly' percise.

As I recall, his implementation showed dramatic improvements in memory consumption.

(All GC schemes are tradeoffs.)


>> The Boehm collector cannot move objects around, the D one can.
> Oh it can? Really?

Yes. D, for example, requires that objects not be self-referential for this reason.


> I would love to see how well interfacing with any C library
> works, if the D garbage collector actually does that.

The current D GC does not do that, but it can. It will work fine with C 
libraries as long as a pointer to the data is retained on the stack, as it 
naturally will be by passing it as a stack parameter to a C function. Roots 
found on the stack would automatically pin the object.

I know this works because I implemented it for a Java VM back in the 90's. 
Someone wrote a paper about a similar scheme calling it a "mostly copying 
collector".


> Also I'm talking about what the D garbage collector currently actually does, and
> not what it could do.

I think it would be more useful to talk about what it could do without language 
changes.


> If we actually would implement arc, it would most likely
> take less time then a full blown proper gc and we would end up with better
> performance than we currently have. Beating the 300% slowdown which the current
> GC imposes is not that hard.
>
> If we however keep arguing what a GC could do, we will be stuck with the
> impercise mark & sweep forever. (or at least the next 5 years)

I believe the performance claims of pervasive ARC are unjustifiably optimistic 
and based on unproven technology that has never been implemented anywhere.



More information about the Digitalmars-d mailing list