How to Improve Link Performance for a Large C++ Application in VS2005

How to improve link performance for a large C++ application in VS2005

If you're using the /GL flag to enable Whole Program Optimization (WPO) or the /LTCG flag to enable Link Time Code Generation, turning them off will improve link times significantly, at the expense of some optimizations.

Also, if you're using the /Z7 flag to put debug symbols in the .obj files, your static libraries are probably huge. Using /Zi to create separate .pdb files might help if it prevents the linker from reading all of the debug symbols from disk. I'm not sure if it actually does help because I have not benchmarked it.

How to speed up c++ linking time

I'm not aware of any parallel linking tools; I do know that Incredibuild does not allow it.

The biggest tool in your toolbox for avoiding link times is the appropriate level of abstraction. If your link times are long, it may be because objects know too much about other objects. Decoupling them is then the key -- through abstract interfaces (perhaps using the PIMPL paradigm), or though other methods such as event passing.

The overhead for linking projects through Project Dependencies is also quite high. If your target platform is Win32 only, or primarily, you may consider using a header to link your dependent libraries via #pragma comment(lib, "pathToLib").

How do YOU reduce compile time, and linking time for Visual C++ projects (native C++)?

It may sound obvious to you, but we try to use forward declarations as much as possible, even if it requires to write out long namespace names the type(s) is/are in:

// Forward declaration stuff
namespace plotter { namespace logic { class Plotter; } }

// Real stuff
namespace plotter {
namespace samples {
class Window {
logic::Plotter * mPlotter;
// ...
};
}
}

It greatly reduces the time for compiling also on others compilers. Indeed it applies to all configurations :)

Low performance of Incremental linking in Visual Studio C++

Set "Use Library Dependency Inputs" in the Linker General property page for your project. That will link the individual .obj files from the dependency .lib instead of the .lib, which may have some different side effects.

How do I speed up visual studio with a large number of projects?

There are a whole bunch of suggestions in this question: Very slow compile times on Visual Studio. A combination of a few of these will definitely help to some degree

Tips on reducing c++ linking time

I dealt with this for years at a previous job. The GNU linker simply has serious performance problems when linking large numbers of static libraries. At one point, link time was on par with compile time, which we found so strange we actually investigated this and figured it out.

You can try to merge your static libraries into a "super-object" before linking. Instead of linking like this:

$ g++ -o program program.o $STATIC_LIBS

You could try this:

$ ld -r -o libraries.o --whole-archive $STATIC_LIBS
$ g++ -o program program.o libraries.o

Note that this method gives the linker less opportunity to exclude unused object code, so your binaries may increase in size somewhat.

Very slow compile times on Visual Studio 2005

The Chromium.org team listed several options for accelerating the build (at this point about half-way down the page):

In decreasing order of speedup:

  • Install Microsoft hotfix 935225.
  • Install Microsoft hotfix 947315.
  • Use a true multicore processor (ie. an Intel Core Duo 2; not a Pentium 4 HT).
  • Use 3 parallel builds. In Visual Studio 2005, you will find the option in Tools > Options... > Projects and Solutions > Build and Run > maximum number of parallel project builds.
  • Disable your anti-virus software for .ilk, .pdb, .cc, .h files and only check for viruses on modify. Disable scanning the directory where your sources reside. Don't do anything stupid.
  • Store and build the Chromium code on a second hard drive. It won't really speed up the build but at least your computer will stay responsive when you do gclient sync or a build.
  • Defragment your hard drive regularly.
  • Disable virtual memory.

How to improve Visual C++ compilation times?

One thing that slows down the VC++ compiler is if you have a header file that initializes concrete instances of non-trival const value types. You may see this happen with constants of type std::string or GUIDs. It affects both compilation and link time.

For a single dll, this caused a 10x slowdown. It helps if you put them in a precompiled header file, or, just declare them in a header and initialize them in a cpp file.

Do take a look into the virus scanner, and be sure to experiment with precompiled headers, without it you won't see VC++ at its best.

Oh yeah, and make sure the %TMP% folder is on the same partition as where your build is written to, as VC++ makes temp files and moves them later.

ways to improve the launch speed of C++ application

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.



Related Topics



Leave a reply



Submit