Wednesday, September 12, 2007

Profiling a dynamic enumerator problem with XPRF

A recent post on the sw-gis Yahoo! Group made me think that this might be a good example to demonstrate how to use the XPRF Magik class to profile your Magik code and help you find potential bottle necks in it.

Because the post did not say so explicitly, for the purposes of this exercise I am assuming the "dynamic enumerator" referred to is the one that makes use of the methods :can_match?() and :match_string(). (Sometimes people use the term "dynamic enumerator" to refer to the core extensible enumerator functionality or the PNI "dynamic enumerator" functionality.)

The first thing I would do would be to do a profile analysis on the :match_string() method on that particular object. An analysis will tell you if you have an issue with database access or maybe some code inefficiencies in your match_string() method.

You could do that as follows...

temporarily rename your subclassed some_object_name.match_string() method to some_object_name.debug!match_string()

create a new method...

_method some_object_name.match_string(_gather args)
_global x_profile
_local ok?, result
(x_profile,ok?,result) << xprf.new_from_send(:debug!match_string|()|,_scatter args)

_return result
_endmethod
$


Then try to open the some_object_name's editor again in such a way that your match_string() code is called. Likely it will take longer now than before because all the match_string() code is being run through the XPRF profiler. When the list is populated in the editor you will be ready to investigate the performance profile.

First, make sure that the global x_profile was populated...


MagikSF> x_profile
$
a sw:xprf


If it is populated, you can use various interfaces to review your profile. The least user-friendly is to call x_profile.basic_report(). This will give you potentially hundreds of lines of output at the Magik prompt... a bit overwhelming if this is the first time you have done this.

Another option is to use the :xprf_dialog class. By default it is not loaded into your image, so you need to load the :profiler_magik_gui module into your current image. Use the sw_module_dialog.open() to load the module or...


MagikSF> sw_module_manager.load_module(:profiler_magik_gui)
$


Once the module is loaded you can use the following Magik command to give you a more user-friendly GUI that will show you expandable lists of all the methods that were called within the context of your profiler.


MagikSF> xprf_dialog.open(x_profile)
$


Use that tool to see where the bulk of your time on the match_string() is being spent.

Possible problems you might have in your match_string() code...
- inefficient code in loops
- select predicates on non-indexed fields

Things that you could investigate to improve performance include:
- make your code more efficient
- index any columns that you are writing a predicate against.
- if the table contents are not changing very often you might consider caching the strings you get from the table in a reusable rope (eg., shared_variable) and only read the data from the table once per session in order to populate the cache

If all those things do not improve the performance to the degree that you would like, then you may want to consider using the CASE tool to configure that field as a "catalogue mapping". That will provide a different field editor but still give you the control over what goes into that field.

FME SOM Demo is now online

A Flash video of the Smallworld FME SOM Demonstration is now online. Click here to view it. The flash file size is about 9MB so it might take a few minutes to download.

(Unlike my attempts at the demo at the Smallworld Users Conference this presentation does not include any blue screens :) )

Smallworld/FME Configuration Tips and Tricks

The Smallworld 2007 Americas Users Conference came to an official end yesterday evening. I had the good fortune of being able to present a paper at the conference entitled "Smallworld Core Spatial Technology and FME: Configuration Tips and Tricks". The PowerPoint slides are available for download here. If you do not have the PowerPoint application then you can view an HTML version of it that requires Internet Explorer and ActiveX by clicking here.

[NOTE: the contact information at the end of the presentation is now outdated. I now work for iFactor Consulting. You can find my new contact information in the Contact Information section on the side of this blog]

I had also agreed to help Mark Stoakes from Safe Software at his FME hands-on workshops by demonstrating the use of the Smallworld FME SOM. At both workshops my computer blue-screened just as I started the demo. That was very unfortunate because there was not enough time to debug the problem during the session. So I will be putting together a description of what I did and posting that here and on FMEpedia. (I discovered later that the problem had to do with my laptop being connected to a docking station which received intermittent power and therefore somehow messed up the parallel port on which my Smallworld license dongle was connected.)

If you received a GE USB Stick in your swag bag and, like me, were not at the session where the password was revealed, try '1111'.


Thursday, September 6, 2007

ACEs, ACEs, everywhere

I recently tried to make a copy of an ACE in the Physical Network Inventory (PNI) product. The out-of-the-box ACE is called "Physical NI User". So I thought that all I needed to do was make a copy of that ACE, call it something like "Physical NI User New", and then modify the application registration code to include...

:ace_name,"Physical NI User New"


Apparently that was not enough. If you want to have two user groups use different ACEs, you definitely need to change the application registration :ace_name. But you also need to change the ACE name in the following XML configuration files:

in a suitable application config.xml file
  • verify config/framework_data/map_type[@ace_name] has the name you are expecting
  • verify config/plugins/plugin[@class_name="pni_editor_manager"]/property[@name="ace_name"]["value"] has the name you are expecting
  • verify config/plugins/plugin[@class_name="document_manager"]/document/document_properties/property[@name="ace_name"]["value"] has the name you are expecting
In addition, if you have specified any bookmarks for an ACE, they are "hardcoded" for the ACE in which they were originally created.

The typical symptom which indicates that some of the above-mentioned ACE settings are incorrect is the one where you look at the object control plugin and notice that the v/h/s settings are not what you thought you had set them to in the current ACE. Most likely you did set the v/h/s settings correctly but one or more of your application configurations are still pointing to an ACE that you are not expecting it to.

Tuesday, September 4, 2007

See you at the Americas Users conference

The Smallworld 2007 Americas Users Conference is coming up in less than one week near Denver, Colorado. I look forward to seeing many of you there. Hopefully we will learn a lot about the new Smallworld/Oracle initiatives.

I will be presenting a paper on Tuesday entitled "Smallworld and FME: Configuration Tips and Tricks". Safe Software will be presenting some good hands-on workshops about how to use their FME tool so I won't be covering that territory again. But I will be presenting how to get your Smallworld system set up with the FME interface so that you can do the cool things that Safe Software will show you in the workshops. I also plan to give a short FME SOM (Spatial Object Manager) demonstration during one of the FME workshops.

If I don't see you at the presentation or workshop, please feel free to come by and say "hello" at the Red Planet Consulting booth where I will be during the exhibition times.

See you there!