D2 weak references
Leandro Lucarella
llucax at gmail.com
Wed Apr 22 10:24:57 PDT 2009
Leandro Lucarella, el 22 de abril a las 14:19 me escribiste:
> > Unfortunately, that is not efficient. The state used by the GC is in
> > flux during the sweep phase, so there is no easy lockless way to access
> > that data. Having to acquire a lock on every weakref dereference
> > absolutely kills performance.
>
> The sweep phase don't touch mark bits. I can't possible understand why
> you should synchronize access to a (temporarily) read-only variable.
>
> Mark bits are only written when:
> 1) Clearing all the mark bits before marking (this is done with all
> threads running now, and this is what it should be changed to be done
> when all threads are suspended)
> 2) Marking (threads are suspended in the current implementation)
>
> > I'm definitely open to hearing more ideas on how to efficiently
> > implement.
>
> The only performance penalty of my proposal would be incrementing the time
> the world is stooped a bit (adding the marks cleaning phase there).
> I think is a fair price to pay (being that mark bits are implemented using
> bitmaps, it should be pretty fast resetting all bits to 0) for an easy and
> safe weak references implementations.
I forgot to mention that at allocation time, the mark bit should be set to
keep the invariant that all live data has the mark bit set. I don't think
this should impose a very big performance penalty either.
--
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Ideas claras, libertad y patriotismo, para mejorar la calidad de vida;
claro que todo con mucha calidad, porque, joven, ideas claras, libertad
o patriotismo tiene cualquiera.
-- Ricardo Vaporeso
More information about the Digitalmars-d
mailing list