LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cluster performance: "single unbundle" vs "multiple unbundle"

I have a doubt about the Unbundle cluster instruction.

Is there any performance issue when using "multiple unbundle" cluster when comparing with a "single unbundle"?

Consider that I'm using the data inside a subVI (without the need of showing data in the Front Panel)

 

See the attached example:

Example 1 uses only a single unbundle and the wires go straight to the "control" (control can be a more complex logic like a subVI)

Example 2 uses multiple unbundle and each unbundle is associated with different instructions

Cluster unbundle.png

 

I'm asking this because the Block Diagram would be more readable (see example below)

Cleaner Block Diagram.png

0 Kudos
Message 1 of 15
(1,344 Views)

I believe that unbundling separately creates data copies at each unbundle node.  This could cause big performance and/or memory issues if the cluster contains a lot of data.

 

So, for normal use, it doesn't really matter, but if you need the ultimate in performance, use one unbundle and expose the elements you need to unbundle.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 15
(1,336 Views)

@billko wrote:

I believe that unbundling separately creates data copies at each unbundle node.  This could cause big performance and/or memory issues if the cluster contains a lot of data.

 

So, for normal use, it doesn't really matter, but if you need the ultimate in performance, use one unbundle and expose the elements you need to unbundle.


I suspect the compiler would most likely optimize this since it is clear that the data will not get modified. It is being read and passed to a subVI. The copy for the subVI will be there regardless. More likely than not both code constructs would compile down to the same code under the hood.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 15
(1,332 Views)

@Mark_Yedinak wrote:

@billko wrote:

I believe that unbundling separately creates data copies at each unbundle node.  This could cause big performance and/or memory issues if the cluster contains a lot of data.

 

So, for normal use, it doesn't really matter, but if you need the ultimate in performance, use one unbundle and expose the elements you need to unbundle.


I suspect the compiler would most likely optimize this since it is clear that the data will not get modified. It is being read and passed to a subVI. The copy for the subVI will be there regardless. More likely than not both code constructs would compile down to the same code under the hood.


I had a huge performance increase when I went to a single unbundle node for a cluster that contained a huge array.  I had unbundled different elements in different places just like the OP showed and it was slowing everything to a crawl, but when I unbundled everything in one place, it went away.  I was surprised as heck, and that was the last thing I tried because I believed the same thing you did.

 

Edit: Well of course it was the last thing I tried, because it worked, but you know what I mean.  😄

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 4 of 15
(1,324 Views)

@billko wrote:

@Mark_Yedinak wrote:

@billko wrote:

I believe that unbundling separately creates data copies at each unbundle node.  This could cause big performance and/or memory issues if the cluster contains a lot of data.

 

So, for normal use, it doesn't really matter, but if you need the ultimate in performance, use one unbundle and expose the elements you need to unbundle.


I suspect the compiler would most likely optimize this since it is clear that the data will not get modified. It is being read and passed to a subVI. The copy for the subVI will be there regardless. More likely than not both code constructs would compile down to the same code under the hood.


I had a huge performance increase when I went to a single unbundle node for a cluster that contained a huge array.  I had unbundled different elements in different places just like the OP showed and it was slowing everything to a crawl, but when I unbundled everything in one place, it went away.  I was surprised as heck, and that was the last thing I tried because I believed the same thing you did.


That is very interesting. I generally would use a single unbundle simply because it fits more in line with my coding style. But it is good to know that it can impact performance if large data is involved.

 

BTW, here would be a cleaned up version of the code beyond what was originally posted.

Cleaner Block Diagram - MAYMOD.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 15
(1,314 Views)

@Mark_Yedinak wrote:

@billko wrote:

@Mark_Yedinak wrote:

@billko wrote:

I believe that unbundling separately creates data copies at each unbundle node.  This could cause big performance and/or memory issues if the cluster contains a lot of data.

 

So, for normal use, it doesn't really matter, but if you need the ultimate in performance, use one unbundle and expose the elements you need to unbundle.


I suspect the compiler would most likely optimize this since it is clear that the data will not get modified. It is being read and passed to a subVI. The copy for the subVI will be there regardless. More likely than not both code constructs would compile down to the same code under the hood.


I had a huge performance increase when I went to a single unbundle node for a cluster that contained a huge array.  I had unbundled different elements in different places just like the OP showed and it was slowing everything to a crawl, but when I unbundled everything in one place, it went away.  I was surprised as heck, and that was the last thing I tried because I believed the same thing you did.


That is very interesting. I generally would use a single unbundle simply because it fits more in line with my coding style. But it is good to know that it can impact performance if large data is involved.

 

BTW, here would be a cleaned up version of the code beyond what was originally posted.

Cleaner Block Diagram - MAYMOD.png


But I so believe what you said that I am even willing to believe I remembered incorrectly.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 15
(1,301 Views)

@billko wrote:


But I so believe what you said that I am even willing to believe I remembered incorrectly.


Oh I could be wrong. I have not tested this myself and I am going with an assumption, not prior knowledge. It is such a simple code construct and I know the LabVIEW compiler is quite smart that it would seem obvious to me that under the hood you would most likely end up with the same machine code. I would definitely defer to anyone who has actual experience with the performance having tried both methods.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 15
(1,297 Views)

When reading the help for "Show Buffer Allocations", the burb for cluster did say:

  • Clusters—Displays buffers for clusters on the block diagram. If you want to reduce the amount of memory LabVIEW requires to run the VI, avoid using hierarchical data structures, such as clusters or arrays of clusters that contain large arrays or strings because LabVIEW cannot manipulate these structures efficiently and might cause a VI to use more memory.

So maybe my experience falls under the "cannot manipulate these structures efficiently" umbrella.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 8 of 15
(1,289 Views)

It probably depends if the unbundle needs to make a copy or not. Also don't forget the unbundle of the IPE structure.

Message 9 of 15
(1,248 Views)

There's some old thread where someone had an array of clusters which included arrays of ~100k elements in each, and just indexing out some other element was really slow. I changed it to IPE and it was improved a lot.

I couldn't find it in a (very) quick search. 😕

 

Now, if such a structure causes issues with a single unbundle i'd expect multiple to make it worse, but hopefully the compiler has improved so it isn't such a big issue anymore.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 15
(1,237 Views)