LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to troubleshoot slow VI.

Solved!
Go to solution
It's my first Labview VI and I am sure I will get more efficient as I go.  The problem here is definetely Kepware OPC server, and I am wondering if anyone knows how to troubleshoot that issue.  The bottleneck is not my 20 event structures.  And since twenty+ shared variables would be required to make the 1 event structure function, I found it tidy to use individual event structures at no apparent performance cost.
0 Kudos
Message 11 of 27
(1,516 Views)

Orion HE wrote:

Oh no!! all of my computer's resources are used up polling for events!!!


You need to do something about that memory usage!

 

Well, your code certainly has way too many event structures, as others have already mentioned. Some of the event structures even have data dependency that forces them to execute serially, meaning the loop time is limited to Nx50ms (e.g. the tristate button code sections). There is a lot of code that makes very little sense, but the diagram is too big for my monitor to do any reasonable debugging. What's up with these inner while loops that have no purpose? All your controls are disconnected, and you use value properties and local variables, causing thread switches and extra data copies. Having 50+ error indicators (most a handful of screens out of view(!)) is not proper error handling. Is their only function to suppress automatic error handling???

 

You seem to constantly open new datasocket connections (there are 15 datasocket open functions scattered all over!), that you call repeatedly, sometimes even right after using them with a DS write, but you never seem to close any and you never even use the created connection ID. (there is not a single datasocket close operation anywhere!). (see also)

 

Your front panel has many overlapping objects, causing redraw performance issues.

 

Can you do some memory tracing while running your code?

Message Edited by altenbach on 08-11-2009 05:23 PM
Message 12 of 27
(1,506 Views)

My memory usage is high because I run a PLC programming software, HMI programming software, Email client, web browser with 10+ tabs, Kepserver, NI distributed system manager, and LabVIEW.  I have 4 gigs of ram, so it's no sweat. 

 

The Tristate buttons were the most difficult to get working so I am ok with them the way they are, except the DS open/close stuff, which I did not know would cause memory leaks.  I originally built the while loops in a self contained VI to test my tristate logic.  When it worked, I brought the whole loop in.  Should I remove the inner loops? 

 

My controls are disconnected because I use value properties and local variables.  Since I need to every single control in the VI to be programmatic, and since NI phone support told me to, I thought this was the best method. 

 

Yes, my error handlers are to supress errors, mostly timeout issues.  In troubleshooting my slow VI I thought that error handling forced functions to work serially through the error out connection.  So I thought giving individual error handlers would make the VI run more...parallel. 

 

Overlapping objects are required for me to emulate the C-more touch screen that is already in place.  The C-more touch panel has overlapping objects, do to the high concentration of data that we fit on any one screen.  So Labview needs to run the same way since I am building a redundant HMI to replace functionality of the C-more in case of a failure. 

 

Is memory tracing the same as "highlight execution"?

 

I tested a new VI with a single DS read on a shared variable and it still takes 11-15 seconds, because my OPC server takes 11-15 seconds to get the latest data.

 

Thank you for looking at my code and trying to understand what I am hoping to accomplish.

 

 

0 Kudos
Message 13 of 27
(1,485 Views)

Full disclosure: I have not looked at your code.

 

All of the third party OPC servers I have touched come with a configuration utility that will let you specify how often the tags are updated. Look for that first.

 

That memory usage is scarry to me as well. You have turned on the switch to makes Windows 3Gig aware?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 14 of 27
(1,480 Views)

Ben wrote:

Full disclosure: I have not looked at your code.

 

All of the third party OPC servers I have touched come with a configuration utility that will let you specify how often the tags are updated. Look for that first.

 

That memory usage is scarry to me as well. You have turned on the switch to makes Windows 3Gig aware?

 

Ben


my tags are set to update at 500 ms, no difference at 50ms.  Why is my memory usage such a concern?  I could open up autocad as well and keep running.  I prefer to have all of the programs I use open to save the time it takes to open them every time I need them.  Is there some legitimate reason not to use my computer the way I do?

0 Kudos
Message 15 of 27
(1,476 Views)

In your task manager, the memory use seems to increase constantly, If this continues, you will run out of memory. (see also).

 

Are you on a 64bit OS?

 

You can debug using "tools...profile...performance & memory".

 

You might also want to use e.g. "process explorer" where you can monitor resource use for each running applications and get more details.

 

If your OPC sever takes 15 seconds to get the data, then that is limiting the loop rate and there is nothing you can do. Maybe you should handle communications in parallel loops to keep the UI responsive.

0 Kudos
Message 16 of 27
(1,474 Views)

I use both task manager and process explorer.  My computer's memory does not increase constantly.  If you are referring to the screen cap I took that was me loading a yet another program after I started task manager to capture and save as a jpg.  I never run out of memory on any of the computers I use regularly.  I have a laptop for performing music live, it does all of my instrument processing and vocal processing real time.  I have a desktop for recording audio and manipulation of audio and video.  And I have this work laptop, and I put them all through the paces, but I know how to manage resources.

Capture.JPG

 

My UI is very responsive.  It's just not getting the values from the OPC server fast enough.

 

 

And I am aware of the memory limitations of 32 bit OS.  But I am also aware that until you hit the wall, performance is not effected.

 

0 Kudos
Message 17 of 27
(1,466 Views)

Orion HE wrote:
...

my tags are set to update at 500 ms, no difference at 50ms.  Why is my memory usage such a concern?  I could open up autocad as well and keep running.  I prefer to have all of the programs I use open to save the time it takes to open them every time I need them.  Is there some legitimate reason not to use my computer the way I do?


Does the OPC utility show them updating that fast?

 

Are you using DSC?

 

What is the update rate in the Shared Varible manager?

 

Have you tried reading the OPC tags using data sockets?

 

Ever since Virtula Memory was invented it is a critical concern for good performance since virtual is orders of magnitude slower than physical memory and your title on this thread is "the Best way...". My experience has taght me to fix the obvious issues first and that memory usage set off an alarm.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 18 of 27
(1,458 Views)
The opc client in Kepserverex shows the tags updating just as slow as Labview, so I know the problem isn't with my code or labview.  I am reading/writing all of my shared variables using datasocket.  I don't believe I have a shared variable manager.  I am using labview 8.6.
0 Kudos
Message 19 of 27
(1,455 Views)

Orion HE wrote:
The opc client in Kepserverex shows the tags updating just as slow as Labview, so I know the problem isn't with my code or labview. ...

That sounds like we are done here, agreed?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 20 of 27
(1,441 Views)