Best practice for OrgVue optimisation with properties and expressions

A mini tutorial to help you make the most of your tenant and datasets.  Note this is a summary article based around optimisation, there is also more detailed coverage of Property Default Options and Property Evaluation Options elsewhere


This article reviews the way in which OrgVue handles calculated data


•    Write expressions in the property value box (not individual cells)
•    Make your expressions as efficient as possible
•    Set up expressions so they re-calculate only as needed
•    Use ‘settemporary’ (and ‘script’ mode) to evaluate all your properties in one
•    Avoid dependencies in your properties
•    Keep your tenant tidy


Write expressions in the property value box (not individual cells)

Where to put expressions


•    Repeating the same expression in each cell adds overhead to the time it takes to evaluate the dataset. This is because as well as being evaluated for each node, the expression needs to be compiled (‘recognised’) for each node.
•    Storing expressions in the property value box means they are still evaluated for every node but are only compiled once
•    Writing an expression directly into a cell should therefore be avoided unless you only want to change one or two nodes

  • If you want to perform an on-the-fly calculation or experiment with writing expressions, use the expression manager
  • If you want to apply an expression to all nodes for a property, you should use a default value

There are 4 options for how the property value is used


‘Value Mode’ options within ‘Edit Property’ dialogue


•    The 4 Value Mode options in the ‘Edit Property’ dialogue are aimed at increasing the flexibility of value population


This gives you flexibility when managing your data

Default value logic

Default value setting

When is the default value used?

Default value

Nodes with an existing value retain that value. If a node has a blank value, it is replaced with the Default Value.

Inherited value

Nodes with an existing value retain that value. Blank nodes ‘look’ up their hierarchy and inherit the value from their nearest ancestor with a non-null value. If all ancestors have a blank value, nodes will take the Default Value.

Fixed value

All nodes will return this value, regardless of what has been entered in the cells themselves.

Initial value

Can only be used when creating a property or new node. Sets the first value for that property of those nodes.

 

•    When using the Default / Inherited / Fixed settings the cells appear to contain a value but are blank when clicked on. Values set using ‘Initial’ are persisted into the cell itself
•    If you want to paste a hard value into cells, “Initial” is a convenient alternative to a !!* splash


Make your expressions as efficient as possible


•    Whilst you can’t be expected to write Gizmo like a developer, there are some simple rules you can use to make your expressions quicker to evaluate and proof check
•    The below example highlights some of these

 

var grades = {
A: 5,
B: 4,
C: 3,
D: 2,
E: 1
}

grades [node.appraisalgrade]

Make your expressions easy to follow e.g. by using the shorthand form of IF (called “ternary”)

if (node.matrixmanagerid > 0) then {node.matrixmanagerid}, else node.linemanagerid

node.matrixmanagerid > 0 ? node.matrixmanagerid : node.linemanagerid

Try to keep up-to-date on the newest syntax e.g. expressions like format() are frequently developed to make common functions easier

[node.firstname,node.lastname].join(' ')

node.role.value.concat(' ')concat(node.grade)

node.format('{firstname} {lastname}')

Set up expressions so they re-calculate only as needed

“Auto” evaluation of expressions


•    As OrgVue’s default, every time the data are loaded it scans all the values for every property until it encounters an expression
•    This increases the time it takes OrgVue to load or re-process a dataset
•    As a result of OrgVue having to scan a large number of cells, slow loading especially affects large datasets
•    Using the property value box mitigates this to some extent, but performance can still be dramatically increased by stopping expressions needlessly recalculating

We strongly advise you to select the appropriate Evaluation mode for each property


‘Evaluation Mode’ options within ‘Edit Property’ dialogue

•    There are 6 evaluation options in the ‘Edit Property’ dialogue aimed at optimising expressions.

  • These options reduce the data OrgVue scans and the number of times expressions are re-evaluated, increasing the speed of OrgVue

 

These evaluation types perform 2 functions:

These options determine how OrgVue interprets the property in question (i.e. whether it should be evaluated or not

Evaluation type

Does OrgVue consider this property to require “evaluation”?

Auto

If it finds an expression in any cell for that property (inc. default value box)*

On demand FALSE
None FALSE
Node TRUE
Hierarchical TRUE
Script FALSE

* This is a slow process. It might be that OrgVue scans 50,000 nodes in a dataset to find only the last node has an expression for that property value

And more importantly for performance, these options determine under what circumstances the value of that property is recalculated for a given node, and how

 

Evaluation type

What needs to be changed to prompt a re-calculation of a node’s value?

What happens during re-calculation?

Auto

Any node’s value for that property

Recalculate all the nodes in the dataset

On demand

Force re-calculation by pressing the refresh icon

Recalculate all the nodes in the dataset

None

It will not be recalculated outside of a deep refresh

N/A

Node

One of that node’s values

Recalculate that node

Hierarchical

Recalculate that node and all its ancestors

Script

The property containing node.settemporary got evaluated*

(The value is set via an expression or script executed from outside this property)

N/A

Picking the appropriate evaluation type for each property will increase performance

•    Avoid using the ‘auto’ setting which detects expressions (at a high performance cost) and evaluates them whenever data changes
•    Choose the 'none' setting when no cell for this property should be evaluated as an expression
•    Choose the ‘node’ setting when the expression only needs to be re-evaluated when the node is changed
•    Choose the ‘hierarchy’ setting when the expression is dependent upon the node's descendants e.g. as node.rollup("salary","sum").


If needed, you can ‘force’ or prevent re-evaluation, providing more control

Prevent your expressions being re-calculated when you don’t want them to by adding a “!!” to the end:

•    The results will now be hard-written into the cells (cf. “Initial” value mode)

•    To trigger a recalculation, remove all the values from your property by blank splashing (!!*) into a cell

Force a re-calculation by using one of the following:

OrgVue will refresh a view (re-draw it) when the dataset is recalculated or you click ‘refresh’

OrgVue will recalculate a dataset (re-evaluate its expressions) when: the dataset is opened, you click ‘recalculate’, draw an Org Chart, a filter is applied/removed, the dataset is saved

OrgVue will reload a dataset (update to/from the server) when: the dataset is first loaded, a user clicks reload, the user hits ‘save + reload’, certain trees are rendered


Use ‘settemporary’ (and     ) to evaluate all your properties in one

What?

Rather than typing individual expressions directly into the Default Value box for properties to be calculated, OrgVue enables multiple properties to be set via a single expression held either in a specified property or executed via a script.

Why?

This means only one expression is evaluated for each node but a range of calculated values are returned for multiple properties; this:

  • increases performance in datasets where multiple properties contain calculated values
  • allows the reuse of traversals (expressions calculating up and down the tree) without needed to perform these calculations again/rely on dependency order.


The main settemporary knowledgebase article can now be found here



Avoid poorly ordered dependencies and circular references


•    Dependencies are where 1 property is calculated with reference to another calculated property e.g. Salary (value) > Bonus (10% of salary) > Compensation (salary + bonus)
•    If the first property (Bonus) hasn’t been evaluated by the time the second property (Compensation) starts being evaluated, the second evaluation will fail
•    This can occur cause errors in two places:

•    In the property pane


Because OrgVue evaluates properties from the top of the list downwards, if Bonus is placed underneath Compensation, the evaluation will stop and you will need to re-calculate the dataset for it to start up again. Avoid this by dropping properties in the order they will be calculated.

•    Whilst using settemporary


For settemporary to work, all the expressions it contains must be evaluated at the same time. This means it cannot contain any dependencies. If it does, the whole is expression will fail and none of the calculated properties will given their values.


•    Circular references are instances where 2 or more properties are calculated with reference to each other.
e.g. calculating ‘DOB’ as : node.birthday.age() &  ‘Birthday’ as : node.dob–node.age will not function correctly because both expressions reference the other
•    This leaves a chicken-and-egg scenario that prevents OrgVue calculating either property correctly

Keep your tenant tidy


Dataset Effects on Tenant


•    Your tenant performance depends on 3 main factors:
–    The number of datasets (inc. links and reports) it contains
–    The size of those datasets
–    The amount and complexity of calculations across the tenant


•    To make your tenant run as fast as possible, consider:
–    Deleting old (versions of) datasets
–    Only creating links between datasets that are being consistently used
–    Combine lookup datasets so they do not overlap (ie. no 2 lookups share the same unique id)
–    Follow the advice on dataset-optimisation – especially using settemporary

This article was written by Ben Marshall from the OrgVue consulting team

Have more questions? Submit a request

Comments