HashBits, a lazy way
Lex Spoon
lex at cc.gatech.edu
Fri Jul 11 01:24:21 UTC 2003
John, to solve the issue of transitioning to new VM's, it seems like
you could extend your idea about watching a demarcation line in memory.
How about making the demarcation line be the young-space/old-space that
is already used by the garbage collector? The full invariant would be:
If an object is in old space, or if it has a non-0 identity hash, then
that
identity hash is permanent. Otherwise, a permanent hash has not yet
been assigned.
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.
This approach will get rid of the lion's share of fake hash
calculations, because by far most objects do not survive to be old.
(Try help->VM statistics, and see how few tenures there are!).
And something that is really nice about the approach, is that it
maintains the same format for the on-disk image. Thus it is really just
a trick that is completely hidden inside the VM.
Now, be aware that you have to do one more thing: whenever a tenuring
operation happens, you have to assign a hash to all objects that don't
already have one. Otherwise, you would end up with a lot of 0-hash
objects in old space, which is not an error but it could cause
performance problems.
Lex
PS -- this whole lazy hashing idea is really nice!!
More information about the Squeak-dev
mailing list
|