Kbuild overhaul claims up to 90% faster no-op kernel builds
Lorenzo Stoakes’ 22-patch series attacks single-threaded bottlenecks from toolchain probes and modpost through objtool and module finalisation.
Lorenzo Stoakes of ARM has proposed a 22-patch kbuild overhaul that targets the single-threaded bottlenecks which still dominate many Linux kernel builds.
On hardware ranging from an 8-core M2 MacBook Pro to a 512-thread dual-socket EPYC box, he reports allmodconfig full builds up to 36% faster, incremental rebuilds up to about 70% faster, and no-op builds (make with nothing to do) up to roughly 90% faster. The gains hold for both GCC and Clang.
The changes hit several long-standing costs. Repeated compiler and linker option probes that once ran on every make invocation are recorded once per toolchain. Make’s heavyweight parsing of per-object dependency files is replaced, when little has changed, by a small C helper that stats each dependency once and feeds make a much smaller fragment. Object-to-module bookkeeping that previously grew quadratically with directory size is computed once and reused.
On the serial tail of every vmlinux link, modpost caches section-mismatch lookups that used to rescan the same tables for every relocation. Module descriptors that were emitted as C, then recompiled with full header and objtool overhead for each of more than ten thousand modules, are instead generated as assembly and processed in batches. Kallsyms reads ELF images directly rather than round-tripping through nm and a large sed script to build System.map.
Objtool, another serial choke point, stops hashing DWARF relocations it never looks up by destination, gains a denser relocation cache and a text-sized instruction hash, and can decode instructions in parallel for large link-time runs (capped at 16 threads). Builds that have pigz installed and that pass Rust threading flags see further help on compression and crate work.
Stoakes’ numbers assume related module-version and objtool work already staged for the kbuild tree, plus pigz. He is coordinating the merge with Nathan Chancellor. For kernel developers and CI systems that rebuild constantly, cutting no-op overhead and the final link tail is wall-clock time recovered on every machine.