Build faster with parallel make operations
Daniel Nashed – 9 August 2026 07:15:41
When compiling complex projects parallel compile operations can dramatically speed up the build pipeline.
In my case I was compiling NGINX and also building LibCurl and OpenSSL from scratch.
Both type of build pipelines are running much faster with 4 threads instead of one.
The following lines use up to 4 cores. Usually going beyond the 4 cores is not helpful and could block too many resources on a larger machine.
Specially because the parallel processes would also use more memory in combination.
It turned out that the max of 4 are a good balance.
Another interresting optimization was to let the build container use tmpfs instead of a disk.
In my case I am setting build flags globally. But it would also work with just: make -j4.
-- Daniel
# Use up to 4 CPU cores for make
if [[ -z "${MAKEFLAGS:-}" ]]; then
BUILD_JOBS=$(nproc 2>/dev/null || echo 1)
(( BUILD_JOBS > 4 )) && BUILD_JOBS=4
export MAKEFLAGS="-j${BUILD_JOBS}"
echo "Parallel Build Jobs: ${BUILD_JOBS}"
fi
- Comments [0]