Today I was discussing with one of my colleagues why C++ build systems are slow. We both understand that include literally includes the whole file, so the C++ compiler has to parse a lot of lines of code. But it is kind of one thing that is puzzling for me what the build system is doing before the C++ compiler is invoked.

What I noticed on UE5 projects and on projects in the studio I work, build system thinks for about 20 seconds and then I see in the compiler invocation.

So we have 60K files in the projects. We have 13K source files. And lets say each source files depends of 10-100 header files. So for each object file we need to check one source file and 10-100 header files to make a decision if we need recompile the file or no. So it is from 130K (13K * 10) to 1.3M (13K * 100) checks. On my machine it takes about 6 seconds to stat 1M files. I guess if you just do dumest way possible to check your dependency tree it should take no more than 10 seconds. And honosly you have a lot of room to optimize. For example you can run stat for 60K files and save results it in memory.

So yeah… I do not understand by C++ build systems so slow.

Next - Previous