[ANN] Process-Specific Variables
"Martin v. Löwis"
martin at v.loewis.de
Wed Mar 14 07:23:45 UTC 2007
Andreas Raab schrieb:
> Good question, I don't know (anyone knowing DynamicBindings care to
> compare the approaches?) I've looked at the code in the meantime and it
> does exactly what I thought it would ;-) though there was one thing that
> surprised me: ProcessSpecificVariable caches the computed hash value,
> which I assume it does for performance reasons. The reason this
> surprises me is that I would not have expected this to have a
> significant performance impact, maybe that's just a left-over?
It is indeed for performance reasons. Computing the hash alone,
1000000 timesRepeat:[C hash]
for some class C, on my machine, uses roughly 900ms to run
using the standard class hash, and uses 180ms to run using
the cached hash. A plain C yourself loop uses 120ms. So for
the hashing alone, the speedup is fairly dramatic (factor of
30, roughly). I haven't timed the impact on complete lookup
time for a variable (but could do so if there is interest).
In any case, that's a minor detail of the implementation;
taking it out has no effect other than slowing it a bit
and freeing 4 bytes per subclass.
> But anyway, the idea is pretty cool, and I'm sure I can find uses for
> it. If someone could compare/contrast with DynamicBindings this would be
> greatly appreciated, too.
See the message I just sent. In summary: DynamicBindings uses a stack
walk to find the innermost binding (using notifications). I couldn't
completely understand the implementation, as it has code like
'tmp _ thisContext. "..." tmp sender sender sender swapSender:
something' in it, but I still think that lookup should be fairly
expensive for a deep stack. I also don't like it that it mixes
nested scopes with allowing write access from any point in the
control flow.
Regards,
Martin
More information about the Squeak-dev
mailing list
|