Displayr keeps track of the relationships between all variables and outputs in a Displayr document. Every time you update your data file or variables in your data, Displayr updates all the objects and variables that depend on the object/variable you've changed. The Inputs & Outputs is a visual representation of how everything in your document is connected. As discussed in Viewing Inputs & Outputs to Understand Calculations and Performance, you can view the dependencies for any data/result in Displayr and optimize them.
- Reduce the number of things in the Inputs & Outputs
- Identify bottlenecks
- Shorten the Inputs & Outputs
- Optimize the changeable parts of a Inputs & Outputs
- The impact of data set loading
Many of the other articles in How to Speed Up Displayr cover additional ways for optimizing Inputs & Outputs.
Common misunderstanding: times taken to compute things are constant
A common misunderstanding is that if something takes 10 seconds to compute in Displayr, it will take 10 seconds if redone tomorrow. This isn't true for two different reasons:
- Displayr automatically saves many results and reuses them. This is called caching. Consequently, if a user navigates to a page with a calculation that has already been computed, the result will be retrieved from the cache and won't take any time to compute. This needs to be considered when reviewing Inputs & Outputs, as the results you see in edit mode may be slower than in view mode, and vice versa.
- The amount of time something takes depends on other calculations and network bandwidth. For example, if you are accessing Displayr on a slow internet connection, it will take longer for whatever instructions you give Displayr to be processed. Or, if you have a lot of large conjoint models computing at the same time, everything else will be slower.
Reduce the number of things in the Inputs & Outputs
This is discussed in detail in Reduce the Number of "Things" and the Size of the "Things" in a Document and Reduce the Number of Calculations in a Document.
Identify bottlenecks
The Inputs & Outputs below for calc.1 shows that to perform this calculation, Displayr needs first to calculate A, B, and C.
Displayr will generally attempt to perform calculations in parallel; consequently, C is a bottleneck because C takes much longer than A or B. In this example, the fastest time to calculate these Inputs & Outputs is 2.36 + 0.37 = 2.73 seconds.
Shorten the Inputs & Outputs
That is, if A needs to compute before B, and B before C, then A -> B -> C is the Inputs & Outputs (some people draw the arrows in the other direction...). Sometimes people inadvertently create very inefficient Inputs & Outputs. For example, let's say you create one calculation and have every other calculation linked to it. If you then conduct a trivial modification to this one calculation, it will cause everything else to update. Similarly, if you have a long chain of Calculations, they will all need to be executed in sequence, which will be slower than if you create a structure that permits them to be calculated in parallel.
Optimize the changeable parts of Inputs & Outputs
When optimizing performance, focusing on all Inputs & Outputs is not relevant. Instead, the goal is to focus on the parts of Inputs & Outputs that need to be recalculated.
The example below shows a donut chart with a Control (top-right) that allows the user to filter the chart. When the user changes the control selection, the table is filtered, and the Visualization updates. To understand the time taken for the Visualization to update when the user changes the ages in the ComboBoxS1Age, the only relevant parts are the filter variable and the outputs using the varaible as an input.
The impact of data set loading
Consider the Inputs & Outputs below for the Visualization named viz. The total time taken to show viz will be, reading from right to left, 0.86 + 0.36 + 0.11 + 11.39 = 12.72 seconds.
However, the data set is loaded when the Document is loaded, and, provided the Document stays loaded, it does not need to be loaded again. Consequently:
- In edit mode, once the dataset is loaded, the 11.39 seconds loading time will not occur again.
- In view mode, if the dataset is loaded, the 11.39 seconds loading time will not occur again.
- Once the data set is loaded, the time taken to calculate the visualization is thus only 0.86 + 0.36 + 0.11 = 1.33 seconds.