Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The benefits / disadvantages of unity builds? [duplicate]

Since starting at a new company I've noticed that they use unity cpp files for the majority of our solution, and I was wondering if anyone is able to give me a definitive reason as to why and how these speed up the build process? I would've thought that editing one cpp file in the unity files will force recompilation of all of them.

like image 550
Stowelly Avatar asked May 11 '09 12:05

Stowelly


3 Answers

Very similar question and good answers here: #include all .cpp files into a single compilation unit?

The summary seems to be that less I/O overhead is the major benefit.

See also The Magic Of Unity Builds as linked in the above question as well.

like image 59
akent Avatar answered Nov 11 '22 16:11

akent


Lee Winder posted his experiences with the Unity Builds - The Evils of Unity Builds

His conclusion is:

Unity builds. I don’t like them.

like image 40
mloskot Avatar answered Nov 11 '22 17:11

mloskot


It's because it saves redundant work. Redundant parsing and compilation for dependencies. Linking is also much more complex -- you either have your exports all in one object (or a few), or it's separate redundant exports across most of the target's object files. Fewer objects result in less I/O and reduced link times. Depending on your setup, inclusion could be a problem -- on the "unity build" system I use, the build is ultimately CPU and/or memory bound.

like image 2
justin Avatar answered Nov 11 '22 15:11

justin