21

Is there any way, to optimalize linking time in MS Visual studio C++ (2005) ? We're using Xoreax Incredibuild for compilation speed up, but nothing for link.

Currently every linking takes about 30seconds. When I turn on incremental linking, takes abou 35-40 seconds. ( No matter if i compile project with or without incredibuild )

Is there any way, how to profile linker and watch how long what takes ? Or any tool for paralel linking ? Or any tips for code optimalization to speed up linker ?

Thanks for reply Ludek Vodicka


Edit:

Thanks for first replies, and additional info:

  • Whole Program Optimization and link-time code generation is already off.
  • PIMPL idiom is already used when possible
  • other static libraries are already included via #pragma comment(lib, "pathToLib"). (also because of easier maintenance]
  • HW : quad core q6600, 8GB ram, 3x WD raptor raid 0. Windows Vista 64bit
Ludek Vodicka
  • 1,610
  • 1
  • 18
  • 33
  • 30 seconds sounds not that much to me. If you do sensible development how often do you execute a compile/link cycle? Maybe every 10-30 minutes if you are fast. Does it really matter if you have to wait 30 seconds there? – lothar May 28 '09 at 20:09
  • How long does the parallel compilation phase take? How many targets do you typically build at a time? If the compilation phase takes 10 seconds and you only build one target, I don't have a whole lot of sympathy for your situation. :) – bk1e May 29 '09 at 06:50
  • When developing new features, We're compiling every 10-20minutes as you said, but when searching and fixing bugs, it could be every minute ;-( Whole project compilation take about 2 minutes and building one target. When compiling only one changed file, fil compilation takes about 3 seconds and linking about 35 secs ;-( – Ludek Vodicka May 29 '09 at 07:02
  • (Compilation runs on 3 comps with 14 cpu cores) – Ludek Vodicka May 29 '09 at 07:04
  • you can read my post in this thread. http://stackoverflow.com/questions/143808/how-to-improve-link-performance-for-a-large-c-application-in-vs2005/9733242#9733242 – Kaleidos Mar 16 '12 at 07:12

4 Answers4

14

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").

  • 1
    Setting a dependency via the Project Properties | Linker | Input or via pragma comments is the same. Setting a project dependency does not automatically link against (I think it used to in older versions), it only requires the first build before the second. – Mahmoud Al-Qudsi May 11 '12 at 07:48
9

If you can live without the optimization, turn off link-time code generation (remove the /GL switch or in properties c/c++ -> Optimization -> Whole Program Optimization. For the linker remove /ltcg or use the Link Time Code Generation Setting). This will make the compiler slower though, as code generation now happens during compile time.

I've seen projects that take hours to build with /GL+/LTCG, mere seconds without (this one for example: http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/750ed2b0-0d51-48a3-bd9a-e8f4b544ded8)

Ben Schwehn
  • 4,505
  • 1
  • 27
  • 45
2

Have you considered improving hardware?
Do you use a separate physical hard drive for for the build? What kind of drives do you use?

As a general suggestion: throw in some memory, get a Velociraptor, put only sources and build directory there, measure again. If that helps, consider a RAID 0.

I've heard reports that upgrading from an XP core to an W2K3 core improved build times notably, presumably due to better memory management and caching.

As a suggestion for changing your code, you could move some functionality to a DLL, and link in parallel. But I'd not make such a change just to improve build times.

peterchen
  • 40,917
  • 20
  • 104
  • 186
1

There are some general setting suggestions on Improving link time with IncrediBuild

You can also skip linking of static libs where you won't distribute them using IncrediLink

We found that addition of a signing post build step would stop IncrediBuild from working on following projects, adding a comment to post build was supposed to help

rem IncrediBuild_AllowOverlap

See IncrediBuild_AllowOverlap doc

Michał Powaga
  • 22,561
  • 8
  • 51
  • 62
Greg Domjan
  • 13,943
  • 6
  • 43
  • 59