LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LaunchExecutableEx makes programs run slowly

I've got a "master" application in CVI 5.5 that pumps data to other applications via a named pipe.  I've started using LaunchExecuatableEX so the other apps automatically close when the master application closes.  Seems to work well except the applications run 2-3X slower (i.e. 55 seconds vs 23 seconds) when launcehed via LaunchExecuatableEX compared with starting them by double clicking a desktop shortcut.  Clients are in CVI 5.5, 8.5, and Delphi.

 

The slow down is verified on Windows2000, XP, and Windows 7RC1.  XP and W2K machines are dual core, Win7RC1 is quad core.  Any ideas as to a solution? 

 

I'm going to try going back to using LaunchExecuatable, although its possible I never noticed the slowdown before because I wasn't looking for it, as during most development I used desktop short cuts to lauch the clients while running the server under CVI debugger.

0 Kudos
Message 1 of 6
(4,062 Views)

I haven't found a cure, but on the Win7RC1 quad CPU if all the clients are started with LaunchExecutableEX one CPU is pegged at 100% and the others are barely used.  If I launch all the clients by double clicking their icons, TaskManager shows one CPU at 100% and the other three bounce arround, but average about 50%.

 

Apparently LaunchExecuatableEX causes some kind of processor affinity issue.  The server has 3+Nclients threads, the clients all have at least two threads.

 

My boss likes all the clients terminating as one when the server is closed, and normal usage doesn't have them all running at once.  Perfomance of the most common subset, might be adaquate.   Its being debated, but I'd still like to know what is going on and find a solution.

 

--wally.

 

Message 2 of 6
(4,043 Views)

LaunchExecutable vs. LaunchExecutableEx made no difference on the quad core CPU.  Task manager still shows basically only a single CPU utilized, whereas if I double click each client's icon to start them, all four CPUs show good usage and overall performance is significantley better.

 

Anyone know the SDK call(s) that would be equivalent to double clicking an icon to start a program?

 

My development system has CVI 5.5, 8.01, and 8.51 installed so I assume all the CVI applications are using the 8.51 CVI RTE. 

 

The reason I've stayed with 5.5 unless I require 8.5 features (8.01 is there for projects using the Linux run-time) is the installer.  All the installers after 5.5 have been increasingly bloated and what passes for "enhancements" are of less than zero value to us.

 

--wally.

 

0 Kudos
Message 3 of 6
(4,018 Views)

I think what's happening is that the NI routines are launching the executable as a child process which then inherits the process affinity mask from the parent, which may be specifying a single processor, essentially forcing them all to run on the same set of (possibly one) cores.

 

When you launch from the desktop icon these processes do not have a child relationship to another task I suspect, so they will run on any core as the scheduler decides.

 

You could try doing a CreateProcess call and then set the process affinity mask to allow all of the cores on your system.  The mask is a dword that's a bit map of up to 32 processors.  So setting the 4 LSB's to 1's would tell the scheduler to run the process on any of the 4 processors.

 

If you feel experimental you could get the process affinity mask for the process and see how it's set.

 

I never use LaunchExecutable, I always use CreateProcess, I guess I feel I stand a better chance of understanding process behavior.

 

Menchar

Message Edited by menchar on 02-18-2010 12:45 PM
0 Kudos
Message 4 of 6
(4,003 Views)

Thanks, I'll bone up on CreateProcess and its options.  I have to put this aside for the next couple of weeks to work on something else, but I'll follow up if I find a CreateProcess replacement for LaunchExecutableEX that does not hurt peformance on multi core and allows the launched applications to be automatically closed.  Looks the handle returned in the PROCESS_INFORMATION structure wil let me close the launched applactions.

 

We are trying to maintain the illusion that this set of interacting programs is a single application as far as the user is concerned.

 

--wally.

 

Edit: perhaps this perfromance hit with multi core CPUs should be filed as a bug against the CVI 8.5.1 run time when using LaunchExecutable and LaunchExecutableEX.  Anyone in a postion to test it on CVI 9?

Message Edited by wally_666 on 02-19-2010 07:48 AM
0 Kudos
Message 5 of 6
(3,980 Views)

We have done a lot of work with multi-process applications working together to provide the effect of a single application to the end user.

 

We use CreateProcess exclusively to launch applications.

 

You can kill a process with the handle provided as a consequence of the CreateProcess call, but it's dangerous to use this (TerminateProcess).  Far better to come up with a way to signal the application to terminate itself.   Some IPC mechanism can be used for this, we've used named pipes and memory mapped files (essentially shared memory).

 

You can wait on the child process's handle to signal to determine if it's terminated.

 

Micro$oft recommends using a private windows message to broadcast the terminate message and cause the receiving process to do an ExitProcess call so everything will get cleaned up.

 

 

0 Kudos
Message 6 of 6
(3,963 Views)