LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I track down which (sub)VI is using all of my CPU resources?

Hi,

 

I'm having some trouble debugging a project...

 

Problem:

Every once in a while, all my Vi's in the project seem to freeze up or execute extremely slow. The machine's CPU load rises to 100% (99% for the LabVIEW.exe process). The normal CPU load with the application running is around 10-15%.

Windows and LabVIEW are still responsive, albeit very sluggish. I can run the "Performance and memory" tool but I can't find any abnormalities.

 

Question:

Is there a way to find out what's causing the high CPU load? For example by showing the CPU load per VI in memory.

 

Any input is appreciated.

 

Kind regards,

 

Pieter-Jan

0 Kudos
Message 1 of 7
(3,782 Views)

It is highly likely that you have a loop that has no wait in it.  As a result of this, the loop is spinning as fast as it can, eating up all your CPU time.  Introducing a wait of even 1 ms will work wonders for your CPU usage.  1 ms is too short for us to accomplish anything in, but to a computer, 1 ms is an eternity, and it can perform several tasks in that amount of time without breaking a sweat.

 

[edit]

Oops, I didn't read that it happened randomly which makes it slightly less of a possibility.

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 7
(3,746 Views)

When several VI is running then if you open the task manager -> process then it will show only labview.exe. then if you go to resouce monitor and see then also you will see only labview.exe. So I dont think that you will be able to watch per VI.

 

On the other part if you open chrome with multiple tabs then for all the tabs there is one chrome.exe you can see on the task manager.

 

May be NI has implemented in that way.

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 3 of 7
(3,723 Views)

I'm just going to reiterate what bilko said.  Make sure you have a wait somewhere in each of your loops.  Any event structure, enqueue, wait on notifier, anything else with a timeout, or even a Wait (ms) with a 0 wired to it will off load the CPU so other processes can work.

 

Something like this is almost never random.  Are you building large arrays?  I've seen things slow down when your memory usage gets large. Can you post the VIs?  Maybe another set of eyes will spot something.


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 4 of 7
(3,711 Views)

@Pianne wrote:

 I can run the "Performance and memory" tool but I can't find any abnormalities.



Can you  be more specific what you mean by that? Maybe you are not using the tool correctly or are looking for the wrong "abnormalities".

 

All that should be needed is to enable the profiler, run things for a while until the problem appears, and look at the time column. The offending VI should stick out visibly! Now open the subVI and, if the problem is not clear to you, post it here.

 

For more details, have a look here.

 

Good luck!

0 Kudos
Message 5 of 7
(3,703 Views)

Thank you all for the replies. I was out of the office last week and didn't get a chance to reply untill now.

 

My first thought was also a loop with no timing in it, like billco suggested. The problem is finding which loop is causing the problem, as six seperate loops run continuously and make a wide variety of subVI calls, some static, some dynamic.

 

@altenbach: The profiler will only show VI's that have started and terminated execution. This means that if I start the profiler when the applicaton has already frozen, I can see very little happening.

I could start the profiler before starting any of the VIs, but the problem usually only occurs after hours or days of running. And when it freezes, I can nolonger shut it down properly.

I have attached two logs of the profiler: One during normal operation and one while the application was 'hanging'.

 

@crossrulz: I've checked memory usage in the task manager, and it is not excessive.

The project is a bit large to post here (around 300 VIs).

 

Also, the total CPU load goes up to 100%, but when I tested with a single untimed loop I can only get it to go up to 50% because it's a dual core machine and a single loop can only take over one of the processor cores. This makes me question the theory of the untimed loop...

 

Any ideas?

Download All
0 Kudos
Message 6 of 7
(3,643 Views)

Hello Piane,

 

Didn't you mention that you had 6 parallel/seperate loops.

This said couldn't it then be that you have 2 (or more) loops in parallel both trying to go as fast as possible.

In that case it would be possible that both loops are each  "dominating" one core.

 

Another thing I'm personally curious about.

Can you set (in task manager) the Affinity of the LabVIEW.exe process to only one of the cores?

 

Do you get then 50% (or something in the vicinity of that)?

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 7 of 7
(3,609 Views)