From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Priority Higher than Normal is slower

Solved!
Go to solution

The two subVIs below have exactly the same code, a simple addition.

 

The top subVI is set with a priority of "High" and the bottom subVI with a priority of "Normal". The calling VI is set to "Normal priority". After running, High Priority time is about 20-30x larger than Normal Priority time. Any priority higher than normal except Subroutine gives the same result. Why?

 

I could understand if there were no benefit to make the priority higher but  I am surprised that it makes the subVI runs slower.

Priority testing_BD.png

Marc Dubois
0 Kudos
Message 1 of 3
(2,702 Views)
Solution
Accepted by MarcDub

VIs running at different priorities run in different threads (see http://digital.ni.com/public.nsf/allkb/84ECA015AA496B23862565BC006C0F19 'LabVIEW has five "execution systems", and each execution system allocates threads for four different normal priorities...The "background priority" does not normally have threads allocated for it. VIs running at this priority will use the next higher priority threads when nothing else is available to run.'). So, each call to your high-priority subVI causes a thread switch, and that's what's taking up all the extra time. If you put the entire For loop into the high-priority VI, you'll see that it executes faster than the normal-priority loop.

 

The lesson here is that VIs that do very little should execute in the same priority as their caller. Use differing priorities for long-running VIs, for example ones that loop repeatedly. If you need a simple function to execute as fast as possible, use subroutine priority or inline it.

Message 2 of 3
(2,690 Views)

Thanks, that is what I thought but could not found a reference.

Marc Dubois
0 Kudos
Message 3 of 3
(2,685 Views)