06-29-2022 03:56 PM
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
I'm asking this because the Block Diagram would be more readable (see example below)
06-29-2022 04:04 PM - edited 06-29-2022 04:06 PM
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.
06-29-2022 04:08 PM
@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.
06-29-2022 04:12 PM - edited 06-29-2022 04:20 PM
@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. 😄
06-29-2022 04:22 PM
@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.
06-29-2022 04:31 PM
@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.
But I so believe what you said that I am even willing to believe I remembered incorrectly.
06-29-2022 04:34 PM
@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.
06-29-2022 04:42 PM
When reading the help for "Show Buffer Allocations", the burb for cluster did say:
So maybe my experience falls under the "cannot manipulate these structures efficiently" umbrella.
06-30-2022 12:46 AM
It probably depends if the unbundle needs to make a copy or not. Also don't forget the unbundle of the IPE structure.
06-30-2022 01:53 AM
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.