RC and GC coexistence

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 20 17:45:48 PDT 2014


On Saturday, 20 September 2014 at 19:48:14 UTC, Oren Tirosh wrote:
> Hi everyone. Unlurking to make my first comment here.
>
> Here is an idea for making RC and GC coexist peacefully. I 
> think this technique may be used to make the Throwable 
> transition to RC while keeping full backward compatibility.
>
> A Throwable object would have a reference counter to track the 
> number of RC references to it. It would also have a flag 
> indicating whether there are any outstanding GC references to 
> the object as well. This flag may be implemented by setting the 
> MSB of the reference counter.
>

I was thinking about this recently (and also, Andrei's talk at 
cppcon provided some interesting data).

Most reference count are small. I think it make sense for us to 
propose a ref count system, that allocate on the GC heap, and 
that do not free when the counter saturate.

It would help to:
  - get intrusive refcount without putting too much crap into 
objects (it is all about cache line).
  - get a way to escape RC object to the GC heap (by saturating 
the refcount).

The GC is still there, but do kick in randomly, it simply act as 
a safety net.

Also given the type qualifier in D, the whole synchronization 
thing is embeded in the type, so we can be safe and fast on that 
one. All of this can be done as library.


More information about the Digitalmars-d mailing list