LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

speed problems

HI everybody!

I have a question regarding the optimization of a labview VI.
It's a very big vi and has several sub-VI's. It's meant to grab pictures and
write them to an avi-file and at the same time dealing with several other
functions.
Now, i recognized that, if i put some of the routines in sub-vi's, the
program runs slower than when i leave it in one big vi.
Also, how do i best use the function "priority" in the vi-settings to
optimize it further?

Any advise is welcome!

regards,
Martin Klein
0 Kudos
Message 1 of 7
(3,500 Views)
Hi Martin,

Calling sub-VI's should incur very little over-head (I've heard 1-2usec per call), so calling sub-VI's should not cause much of a problem. Ther are two exceptions to this (that I can think of now).

1) Repeated calls. If you call the sub-VI's frequently (i.e. in a loop) then the call over-head could be an issue. If this is the case, try restructuring the code such that loop is inside the sub-VI. This will reduce the load (of that part of the code) by a factor similar to the loop count.

2) Large data structures. Wiring large structures into/out-of sub-VI's can take conciderable time. Try to pass the smallest amount of data in and out.

Now on the topic of "priority". I suggest you work with the profiler and timers first, to improve the performance of your co
de. Manipulating the priority should be done only after all other possibilities have been exausted. Manipulating priority can cause as many problems as it solves.
If it seems that the only option left is priority then start by identifying those portions of the code that take a long time. Set their priority DOWN, to let other tasks do their work quickly and get out of the way for the "pig" to run again.
If the app is now acceptable, stop. Further changes to priorities code make things worse.

NOTE:
Make sure you have "wait ms timers" in all your loops that let them run only as often as absolutly required.

I hope this helps,

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 7
(3,500 Views)
> I have a question regarding the optimization of a labview VI.
> It's a very big vi and has several sub-VI's. It's meant to grab pictures and
> write them to an avi-file and at the same time dealing with several other
> functions.
> Now, i recognized that, if i put some of the routines in sub-vi's, the
> program runs slower than when i leave it in one big vi.
> Also, how do i best use the function "priority" in the vi-settings to
> optimize it further?
>
> Any advise is welcome!

Just a few comments. SubVIs typically do not slow down
the operation of your VI by very much. If called millions
of times per second, they will account for some overhead
compared to just inline code, but otherwise, it is hard
to measure. An exception to this is when the subVI uses
differ
ent data types and the types need to be coerced
before each call. This is also true of inline code though,
and the reason is really the type coercion, which shows as
a small gray dot on the junction.

The second question about priorities is a good one to ask.
The answer is that priorities are for giving pieces of
your code priority relative to one another and relative to
the OS. Priorities allow for code that is ready to be run
to be scheduled in front of other code, and it can allow
for the lower priority code to be preempted to let the
higher priority code run. This will not normally cause code
to speed up unless something else was hogging the CPU. This
will also cause other parts of the system to seem very
sluggish if your code doesn't give time back on a pretty
regular basis.

To determine what is taking time, try using the profiler
first. That will point out where you might be able to
gain back some time by speeding something up.
0 Kudos
Message 3 of 7
(3,500 Views)
Thank you very much for your advice, i will try that.

regards,
Martin Klein


"Greg McKaskle" schrieb im Newsbeitrag
news:3A7C27B0.C379D454@austin.rr.com...
> > I have a question regarding the optimization of a labview VI.
> > It's a very big vi and has several sub-VI's. It's meant to grab pictures
and
> > write them to an avi-file and at the same time dealing with several
other
> > functions.
> > Now, i recognized that, if i put some of the routines in sub-vi's, the
> > program runs slower than when i leave it in one big vi.
> > Also, how do i best use the function "priority" in the vi-settings to
> > optimize it further?
> >
> > Any advise is welcome!
>
> Just a few comments. SubVIs typically do not slow down
> the operation of your VI
by very much. If called millions
> of times per second, they will account for some overhead
> compared to just inline code, but otherwise, it is hard
> to measure. An exception to this is when the subVI uses
> different data types and the types need to be coerced
> before each call. This is also true of inline code though,
> and the reason is really the type coercion, which shows as
> a small gray dot on the junction.
>
> The second question about priorities is a good one to ask.
> The answer is that priorities are for giving pieces of
> your code priority relative to one another and relative to
> the OS. Priorities allow for code that is ready to be run
> to be scheduled in front of other code, and it can allow
> for the lower priority code to be preempted to let the
> higher priority code run. This will not normally cause code
> to speed up unless something else was hogging the CPU. This
> will also cause other parts of the system to seem very
> sluggish if your code doesn't gi
ve time back on a pretty
> regular basis.
>
> To determine what is taking time, try using the profiler
> first. That will point out where you might be able to
> gain back some time by speeding something up.
0 Kudos
Message 4 of 7
(3,500 Views)
Are you using Win 2000 ?

Regards Møller

"atsw" wrote in message
news:95e8k3$gdtqd$1@ID-65994.news.dfncis.de...
> HI everybody!
>
> I have a question regarding the optimization of a labview VI.
> It's a very big vi and has several sub-VI's. It's meant to grab pictures
and
> write them to an avi-file and at the same time dealing with several other
> functions.
> Now, i recognized that, if i put some of the routines in sub-vi's, the
> program runs slower than when i leave it in one big vi.
> Also, how do i best use the function "priority" in the vi-settings to
> optimize it further?
>
> Any advise is welcome!
>
> regards,
> Martin Klein
>
>
0 Kudos
Message 5 of 7
(3,500 Views)
I am using win95 and win 98 right now.

Martin Klein

møller wrote in message
news:FjTf6.217$1o.17307@news.get2net.dk...
> Are you using Win 2000 ?
>
> Regards Møller
>
> "atsw" wrote in message
> news:95e8k3$gdtqd$1@ID-65994.news.dfncis.de...
> > HI everybody!
> >
> > I have a question regarding the optimization of a labview VI.
> > It's a very big vi and has several sub-VI's. It's meant to grab pictures
> and
> > write them to an avi-file and at the same time dealing with several
other
> > functions.
> > Now, i recognized that, if i put some of the routines in sub-vi's, the
> > program runs slower than when i leave it in one big vi.
> > Also, how do i best use the function "priority" in the vi-settings to
> > optimize it
further?
> >
> > Any advise is welcome!
> >
> > regards,
> > Martin Klein
> >
> >
>
>
0 Kudos
Message 6 of 7
(3,500 Views)
"atsw" wrote:
>I am using win95 and win 98 right now.>>Martin Klein>>møller
wrote in message>news:FjTf6.217$1o.17307@news.get2net.dk...>> Are you using
Win 2000 ?>>>> Regards Møller>>>> "atsw" wrote in message>>
news:95e8k3$gdtqd$1@ID-65994.news.dfncis.de...>> > HI everybody!>> >>> >
I have a question regarding the optimization of a labview VI.>> > It's a
very big vi and has several sub-VI's. It's meant to grab pictures>> and>>
> write them to an avi-file and at the same time dealing with several>other>>
> functions.>> > Now, i recognized that, if i put some of the routines in
sub-vi's, the>> > program runs slower than when i leave it in one big vi.>>
> Also, how do i best use
the function "priority" in the vi-settings to>>
> optimize it further?>> >>> > Any advise is welcome!>> >>> > regards,>>
> Martin Klein>> >>> >>>>>>>

Martin,

I had a large program once that was pretty sluggish until I called sub vi's
using vi server. If you just call sub vi's traditionally (ie putting icon
on diagram) it is loaded into memory when the main program starts. If you
use vi server it is only loaded when its called, and is cleared from memory
after its executed. This is especially useful if vi's are called often.
if you have a large number of sub vi's you may be using alot of extra memory.
0 Kudos
Message 7 of 7
(3,500 Views)