Object identity

Chris Muller asqueaker at gmail.com
Thu Jun 14 04:25:03 UTC 2007


Hi Florian,

> Yesterday I tried again to save all the Letters in a dictionary of
> Players, add all the Players in Magma, then put back the Letters
> inside the Players. But the last part was so slow I had to stop the
> whole process after about one hour. I don't understand this slowliness
> because thoses Letters are only some references to Players which
> should already be inside Magma.
>
> The resulting code gives something like this (a mailbox is a
> collection of Letters):
>
> mailboxes := Dictionary new.
> players do: [:p | mailboxes at: (p login) put: (p mailbox). p mailbox:
> nil.].
> session begin.
> players do: [:p | session root players add: p. session commitAndBegin].
> players do: [:p | |magmaPlayer| magmaPlayer := session players where:
> [:r | r login equals: (p login)]. magmaPlayer mailbox: (mailboxes at:
> (p login)). session commitAndBegin]

Ok, thanks for the code, it looks real good.  Except one thing that
should be done to speed it up is add more than one player per commit.
Add 100 or 1000 per commit.  That should speed up the first part a
lot.

Same comment for the second part.  Instead of commitAndBegin after
each one, do it every 100 or 1000.  You could also choose to commit
"every five seconds".  I know it makes the code less clean, sorry, but
this is one-time "bulk load" code anyway.

You should also send #finalizeOids to the session after each commit.

If it is still slow after doing all that, if you post a MessageTally
spy it will help a lot.

> Perhaps the players references by the Letters in the last block are
> detected in Magma as not yet inserted and it does it again ?

No, the object is available in the collection as soon as it returns
from the commit.

> Do you have an example of use of a transient variable ? I way I
> understand it is that I make the Letters transients so they are not
> serialized inside magma, then I remove the transient property to load
> the Letters in a second pass ?

Yes, the idea is to implement #maTransientVariables on the referencing class:

maTransientVariables
  ^ super maTransientVariables, #('letters')

My idea was to add a new variable temporarily, 'letterIds' or
whatever.  Populate this with some uniquely-identifying string or
number for the letters.  Commit it.

THEN, remove the #maTransientVariables method and enumerate them
again, initializing each from the letterIds.  Finally, remove the
letterIds variable.

This is a cumbersome approach, hopefully the first one will work.

Regards,
  Chris


More information about the Magma mailing list