HashBits, a lazy way
Andres Valloud
sqrmax at comcast.net
Fri Jul 11 03:45:20 UTC 2003
Hi.
> So, if the image asks for the identityHash of an object, and the hash
> field is non-0, you just return the field. If it's 0, you do a
> further check on whether the object is new or old; if it's old, you
> still just return the field. Only if it's a new object *and* it
> has a 0 in the field, do you calculate a new hash.
I don't understand. On one hand, the identity hash bits are in the
header so that access is super fast when they're needed (e.g. method
lookup). On the other hand, adding a conditional branch seems like it
will slow down every single access. ???... does that pay more than
calculating/storing identity hashes for all objects? How does it affect
message sending? What is the value of the ratio below?
numberOfMessageSends / numberOfObjectsCreated
Because if it's >1, then you do more comparisons (is identity hash = 0
ifTrue:ifFalse:) when you look up symbols so you can find methods than
creations of identity hashes. And since all objects are created via
sending #new, the ratio cannot be < 1...
lastHash _ 13849 + (27181 * lastHash) bitAnd: 65535.
I count 3 operations: +, *, and :=/bitAnd:. So if the ratio is >3, then
you lose.
Did I miss anything?
Andres.
More information about the Squeak-dev
mailing list
|