[Vm-dev] A trick to speedup #become: (but not becomeForward:)

Igor Stasenko siguctua at gmail.com
Sun Jul 31 01:12:01 UTC 2011

An interesting observation:

if two oops which we need to swap: oop1 and oop2 taking exactly same
space in memory,
then all we need to do is to swap their memory contents, instead of
scanning heap and updating pointers!

This makes a become operation extremely cheap for such pairs!
As for objects of different sizes, we could still use slow algorithm.

But knowing that if two objects with same size will be swapped much
faster, a developers could adapt their algorithms to exploit this
(use fixed-size objects instead of variable-sized ones etc).

Magma using proxies, which then #becomeForward: to real objects when reified.
This is very costly operation and main reason why it so slow on
loading objects from server.
To speed thing up, a special trick can be used:
  - each time server sends an object ID (instead of real object) it
could also send its size in bytes (or even more clever - you can
encode object size in its ID ;) ).
Then a client will create a proxy for given object and will try to
match the size, if its possible. (nobody said that proxy can't be
variable-sized, right?)

Then once client requesting to reify given proxy with real object from
database, VM will just overwrite a proxy's memory contents with real

Best regards,
Igor Stasenko AKA sig.

More information about the Vm-dev mailing list