[Vm-dev] [ENH] A better finalization support (VM & language side)

Andreas Raab andreas.raab at gmx.de
Mon Mar 8 22:32:18 UTC 2010


Hi Igor -

Could you give us a brief explanation about what you did? The bug report 
doesn't say much and the benchmark below says even less :-)

Cheers,
   - Andreas

On 3/8/2010 1:31 PM, Igor Stasenko wrote:
>
> Please, review the
> http://bugs.squeak.org/view.php?id=7473
>
> There are two sets of changesets - one for vmmaker and other is for
> language-side.
>
> A VMMaker changeset is based on VMMaker-dtl.159.
>
> Here the little benchmark, between old and new weak registries:
>
> { WeakRegistry. WeakFinalizationRegistry } collect: [:class |
>     | registry weaklings time1 time2 |
>     registry := class new.
>     WeakArray removeWeakDependent: registry.
>
>     weaklings := (1 to: 100000) collect: [:i | Object new ].
>     time1 := [ weaklings do: [:each | registry add: each ] ] timeToRun.
>     weaklings at: 100 put: nil.
>     Smalltalk garbageCollect; garbageCollect.
>     time2 := [ registry finalizeValues ] timeToRun.
>     time1 @ time2
> ]
>   {7816 at 41 . 4114 at 0}
>
> While its not much better at first benchmark (since using the same
> approach to store objects in one dictionary),
> while other is significant, since there is no longer need to scan a
> whole collection to detect an items which become a garbage.
>
> Btw, i wonder, why current WeakRegistry using a WeakKeyDictionary
> instead of WeakIdentityKeyDictionary?
> Isn't a weak refs is identity-based?
>
> I am also a bit wonder, why WeakRegistry has to support a copy protocol?
> It may lead to unpredictable behavior once you try to copy such kind
> of container, no matter how well you protect it.
>


More information about the Vm-dev mailing list