We have been working on our project with scons as build system for a few years. Scons is awesome and has improved our development process a lot. There are ~15000 C++ source files initially and as the project evolves source files in other languages(Java/Scala) are added into the code base as well. Then we developed our own builders which manage dependencies and invoke the external tool(javac, scalac) to build those sources, which works really well. Recently I was working on the optimization of current build system and found performance difference between C++ and Java build process:
Environment setup:
Build server with 24 cores, Python 2.7.3, Scons 2.2.0
Command: scons --duplicate=soft-copy -j8
When building java code, CPU usage is easily high observed from top and spanning multiple cores: Java Build
However, when building C++ code, CPU usage is always ~4% and running only on 1 core no matter how many jobs in scons: C++ Build
I've been googling a lot on the internet but could not find something useful. Am I hitting the GIL issue in Python? I believe that each gcc/g++ command should be ran in a separate sub-process just like javac in our own builders, so there should not be GIL here. Is there any workaround to fully utilize multiple cores speeding up C++ build further? Thanks in advance.
As WindLeeWT explained in one of his comments, the cause for the observed behaviour was that ccache
was installed and configured on the server in question. It seems that most of the CPU usage during a C++ build was took by the compilation stage, which was fully avoided due to ccache
. That's why no CPU usage for several cores could be seen within top
.
As soon as they launched a "build from scratch" on another server without ccache
, several cores were running at 90% with 'cc1plus -o ...' as expected.
No performance penalties (GIL etc.) were involved, and neither Python nor SCons degraded performance in any significant way.