Got bit by the UDT parameters (again)

A small anecdote on why to limit your usage of UDT parameters.

We had an elevator template to show a couple of elevators with their neighbour rollers on different levels.

As this was a top view, the same arrangement had to be visualised multiple times and the elevator was only shown on its current level (rounded to the nearest level). So, we decided to turn it into a template, and pass on the parameters that define that level (the motors used, roller structs, position information, …). Complete with clickable parts to show detailed popups.

However, the page was slow to load. Really slow. The page was shown fast enough, but it took over 2-3 minutes to become responsive to clicks.

First I thought it would be related to my database queries (showing 500-ish individual boxes). But even removing those from the visualisation didn’t help. Then I thought it might be related to the moving parts. Those can update the position of various containers, and it might be heavy. But removing those didn’t help either.

So all that was left were the elevators. This wasn’t so big. The template was only used 8 times, and just had visualisation for 6 motors and 4 “roller” structs (holding the data of what’s on the roller) per template.

But I decided to start altering it. Instead of passing the UDT over the template to the smaller motor templates, I could pass the level of the displayed position (as an int), and inside the template fetch the relevant UDTs to pass them on to the smaller templates via indirect tags.

I knew indirect tags are faster than UDTs, but as I was still fetching the entire UDT to pass on to the child template, I thought it would just be the first step.

The result surprised me a lot though. When about half the tags were being fetched inside the template, the screen only took half as long to load. And now that all UDTs are fetched via indirect tags, the page loads in 2-3 seconds.

That’s a 60x speed improvement!!!

And I still don’t get where the difference comes from, the same UDTs still need to be fetched and the same data is displayed. It just makes our template less portable, as now the project-specific tag paths are encoded inside the template.

Maybe this will be better in version 8.0, but for anyone using Ignition now, and having performance problems. I would advice check your UDT usage.

This is a long-standing problem. It isn’t the UDT instance that’s the problem, it’s the use and binding of UDT parameters. Just say no. Construct/pass tag paths as strings then indirect bind individual elements of your UDTs. A side benefit is that it works even when UDTs don’t form a strict hierarchy but have consistent naming conventions. Templates set up this way work with any conforming UDT and any non-UDT tag folder that has conforming tag names.