Magik Performance

There is a database performance page located at db-perf

Help to Determine Performance Issues

You can use xprf and xprf_dialog to help identify performance problems. You can get an xprf results in several ways:

  • new_when_send will return xprf the next time the method is called.
  • new_from_call runs the given proc
  • new_from_send runs the given method on the exemplar.

Constant vs. is_kind_of?()


Summary
You will note the shared constant is much quicker (note the loop amount, 1 million for is_kind of vs 10 million for constant). But, it is really only quicker if you are running the test more then 1 million times. So if you are only calling the test occasionally, then it probably isn't worth having a constant on the exemplars.

is_kind_of? vs rwo_type

is_kind_of? vs inherits_from?


Note from Roger Fretwell: 'is_kind_of?' performs worse the deeper the inheritance tree of an object, and also for RWOs a much faster alternative is to use 'rwo_type', or in PNI 'is_type_of?()'.

Summary
Not much difference at the 100000 times. but if you need that little extra… Use inherits_from?. Use is_kind_of? for less then 1000 iterations.

Sorted_collection vs. Equality_rope


Summary
Use sorted collections over equality testing for IDs.

Equality Property List vs as_symbol()


Summary
Use Equality Property List.

Database Notifications

This could be in the database section, but it is done thru magik, so I put it here. In 4.2 (maybe 4.1) Smallworld introduced the ability to turn off database notifications. This seems to help prevent the database update from triggering all the dependent plugins from running when you are doing bulk modifications. To use:

    _dynamic !notify_database_data_changes?! << _false 
    # Your code here
    # You need to trigger the changes yourself at the end
    aView.notify_suppressed_data_changes()

There is another system in place if the above code doesn't help.

_protect
view.suppress_notification()
#... load all ...
<...>
_protection
view.restore_notification(_false) # use true if you want notifications to be sent at end.
_endprotect
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License