GC finalizer optimization.
kris
foo at bar.com
Tue Apr 11 11:30:56 PDT 2006
Dave wrote:
>
> Comments? Like, how can this break things?
>
> By changing line 129 of phobos/internal/gc/gc.d from:
>
> _gc.setFinalizer(p, &new_finalizer);
>
> to:
>
> ///_gc.setFinalizer(p, &new_finalizer);
> ///
> ClassInfo c = ci;
> do
> {
> if (c.destructor)
> {
> _gc.setFinalizer(p, &new_finalizer);
> }
> c = c.base;
> } while (c);
> ///
>
> gives me about 3x performance in allocating class objects w/o a dtor
> using the following code.
>
> Before:
> D::~this
> C::~this
> C::~this
> 0.829
>
> After:
> D::~this
> C::~this
> C::~this
> 0.258
>
Heh heh heh ;-)
Then, to identify "leaking" resources, the collector only has to check
if there's a finalizer set :)
More information about the Digitalmars-d
mailing list