LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Global vs Local variables in performance-critical loops


@altenbach wrote:

I am surprised that nobody mentioned the shared variable (single process).


I usually only suggest those when a library is already being used.  I just tend of avoid them do to my hatred for Network Published Shared Variables.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 21 of 23
(1,005 Views)

@crossrulz wrote:

@altenbach wrote:

I am surprised that nobody mentioned the shared variable (single process).


I usually only suggest those when a library is already being used.  I just tend of avoid them do to my hatred for Network Published Shared Variables.


Yes a NI rep many years ago warned me about using them. If the need can handle missed updates, and being slow, ... and the application that I am being asked to help fix is "good enough" then I will stick with them. But if I need something reliable they are not an option.

 

Now back to a couple of points I can offer.

 

If the critical loop can spin much faster than the OTHER process can push messages, then Functional Globals can be used just fine. If the critical loop, however can be stalled and possibly miss and update, Queues are the way to go in most situations. I used to wrote round-robin buffers in the form of Action Engines before queues were made polymorphic. But now that they are polymorphic and data can e transferred "in-place" with the queue just passing a handle to the data, it is had to beat the performance.

 

In two recent project I need to process data vey fast and multiple queues let me implement a type of bucket brigade approach to process that data. I was able to sample 32 DIO lines coming in at 400MHz, demux the signal on a single data line into two channels of info and then decode from the binary stream to audio signals and then do live FFTs of the audio signal. Queues were used between each of those steps and it made use of all of the cores in the machine.

 

In my opinion Queues kick-butt and Stephen has really made a mark on what LV can do when he implemented the polymorphic queue.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 22 of 23
(998 Views)

@Ben wrote:

If the critical loop can spin much faster than the OTHER process can push messages, then Functional Globals can be used just fine. If the critical loop, however can be stalled and possibly miss and update, Queues are the way to go in most situations.


You might actually want to consider a RT FIFO when it comes to sending messages to a time critical loop in an RT system.  Less jitter, otherwise almost identical to a fixed sized queue.

 


@Ben wrote:

In two recent project I need to process data vey fast and multiple queues let me implement a type of bucket brigade approach to process that data. I was able to sample 32 DIO lines coming in at 400MHz, demux the signal on a single data line into two channels of info and then decode from the binary stream to audio signals and then do live FFTs of the audio signal. Queues were used between each of those steps and it made use of all of the cores in the machine.


This situation meets the definition of Streamed Data and you used a Producer/Consumer, with one consumer also being a producer for another loop.  Very common design pattern.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 23 of 23
(993 Views)