S
S
Sergey Savostin2012-10-01 10:09:45
Programming
Sergey Savostin, 2012-10-01 10:09:45

Compilation speed increase?

I wanted to somehow speed up the compilation of a C ++ project that has already grown to something decent.
I would like to hear from experienced comrades as some advice on how to organize the project / code (for example, do not use boost), and what primarily affects the compilation speed from hardware (CPU frequency, manufacturer, speed or memory size, hard drive speed , its defragmentation, free space, file system, whether it greatly speeds up (precisely compilation) SSD, etc.). Does it make sense to disable the antivirus during the build? Maybe there are some shamanism that I don’t even know about? :)
Windows, Visual Studio, if it matters, but Linux and platform-independent options are also interesting.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
B
bogolt, 2012-10-01
@bogolt

SSD, in theory, should not affect, because the bottleneck is the processor and not the disk. I experimented, threw the project into tmpfs (file system in RAM) - the build speed did not change. However, it is possible for large projects to have a difference, but it is unlikely to be significant.
If the processor is multi-core, tell the build system to use more of these same cores ( make -j N ( where N is 1.5 * number of cores ) ).

E
Evengard, 2012-10-01
@Evengard

It makes sense to disable anti-virus (at least Microsoft Essentials) - it likes to plug small files, significantly lowering I / O.
Under Linux, if you often recompile, I can only advise ccache.

V
volkodavua, 2012-10-01
@volkodavua

Well, for starters, install Visual Studio before Intel Parallel Studio will increase both the speed of compilation and the operation of the program itself on multi-core processors.

G
Gribozavr, 2012-10-01
@gribozavr

1. Use clang.
2. Use PCH.
3. If you have a lot of templates, then compile in release (compilation in debug is slower than in release due to large I / O for huge debug information for all instantiated templates)
4. SSD speeds up compilation. But it speeds up compilation even more *a lot* of RAM (at least 1Gb per core for the compiler itself, and the rest goes to disk cache).
5. If you are interested in speeding up incremental builds, take a look at CMake + ninja. This speeds up incremental compilation a lot (if a couple of .cpp files have changed).

R
rtorsten, 2012-10-01
@rtorsten

The most versatile tool is parallel assembly, if not already in use. In MSVC, in the project properties - multiprocessor compilation. For make and most other build systems, the -j<number of parallel builds> flag, which is usually equal to the number of processors/cores.
There is also a similar question on stackoveflow .

P
Puma Thailand, 2012-10-01
@opium

buy a top processor, take 32 gig memory and an ssd disk and rejoice, well, compile in the release options, not debug.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question