Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ways to improve the launch speed of C++ application

Recently, my boss asked me to improve the launch speed of our application, the AP was written with C++. The AP is a little big, it used 200+ dll, Windows needs long time to enter the main() function. I tried these two ways, but still can't make our boss happy.

  1. delay load dll http://msdn.microsoft.com/en-us/library/yx9zd12s(VS.80).aspx
  2. use EDITBIN to to modify EXE http://msdn.microsoft.com/en-us/library/xd3shwhf(VS.80).aspx

Are there other ways to improve it? Thanks in advance.

like image 672
Yigang Wu Avatar asked Feb 02 '10 11:02

Yigang Wu


4 Answers

You need to profile your application in order to determine the true cause of the slowdown. For example, it could be that you are spending most of the time in some initialization routine of one the .dll's you are loading. Go find yourself a good profiling tool and then determine where the bottleneck is.

like image 71
zr. Avatar answered Nov 18 '22 01:11

zr.


Jeez! Reduce that DLL count!

Of course, if you're gonna load 200 DLLs on startup, it's gonna incur heaps of hard page faults, and take forever to boot (like 3ds max).

Rethink your DLL strategy. Combine many small DLLs into larger ones. I seriously doubt you need 200+.

And watch Raymond Chen's Five Things Every Win32 Programmer Needs to Know.

like image 45
Alex Budovski Avatar answered Nov 18 '22 03:11

Alex Budovski


A couple of things I guess you need to know:

  • Many small files is way slower then a couple of big files
  • Disk access is much slower then memory access (DLLs need to be loaded from disk)

Reducing the amount of DLLs is a must in this situation. Maybe you can combine then, but I guess it's a modular design, which means, most of the times, they cannot be combined.

You could also load the DLLs on use, instead of on opening of the program and only load the necessary DLLs to load the program on startup.

Or you could even delay the loading of DLLs by first starting the program with the necessary DLLs and then load the others, on order of importance to use.

like image 2
Michiel Avatar answered Nov 18 '22 03:11

Michiel


If you have access to the code of the dlls ( or some of them ) you could look for candiates to staticly link. If you can convert a bunch of them to static libraries, you could speed up the startup dramaticaly.

like image 1
DarthCoder Avatar answered Nov 18 '22 03:11

DarthCoder