Build2 publishers3 min readPublished
Lorenzo Stoakes' Kbuild patches bring a clean Linux kernel build down to 15 seconds
Lorenzo Stoakes' AI-assisted Kbuild patches cut a clean kernel build from over 22 seconds to 15 on one dual-EPYC machine in Phoronix tests. Getting to 10 seconds is a separate bet on next-generation EPYC hardware.
The Engineer · Build desk
What happened
- The patches remove bottlenecks in Kbuild, the kernel's build system, that were limiting how much of a build could run in parallel.
- On the same machine, an allmodconfig build with every possible module enabled fell from 169 seconds to 134.
- Stoakes' own cover letter reported a dual EPYC 9754 server with GCC going from 28 to 20 seconds for a defconfig build.
- Stoakes posted the v4 series this week at 22 patches, and some of them have already been picked up in kbuild-for-next.
Compiled by The EngineerSomething wrong?How this is made
Why it matters
- constraint On machines this wide, extra cores stop helping while GCC compiles each file on one thread, so further gains have to come from build-system stalls like the ones this series removed.
- decision Kernel CI and bisect setups that want the claimed 70% incremental-build gain now have to apply a pending out-of-tree series and rebase it as review continues.
- precedent The series gives other build-system maintainers a public example of using LLMs to find parallelism stalls while the resulting patches go through normal list review.
Larabel ran both builds on the same dual EPYC 9575F machine, so nothing changed on the hardware side [1]. The cut works out to about 32% of build time, a speedup of about 1.47x [1].
His article opens with "The coffee window is closing." [15] The 10-second part is a bet. "Though with next-gen processors I am betting on 10 seconds," Larabel wrote [8]. According to Tom's Hardware, the bet is on AMD's Zen 6 EPYC 9686F with MRDIMMs and PCIe Gen6 storage [9]. Larabel lists that chip as coming up, with a 5.0GHz boost clock and 384MB of L3 cache [18]. For a sense of how slowly hardware moved this number before, he recalled the EPYC Milan review "finally breaking the 30 second mark" [12]. On this evidence, Kbuild work got the build to 15 seconds. The remaining five seconds depend on a chip that has not shipped.
Stoakes went after bottlenecks in the Kbuild code "that were reducing the parallel potential of the kernel build process," Larabel wrote [4]. With 256 threads available [2], any stretch where the build has no work to hand out leaves most of the machine idle. The shorter the build, the larger the share of wall time those stretches take. The compiler sets the other limit. "At least until compilers achieve parallelizing compilation of individual source files, the very highest core counts aren't necessarily the best for build servers," Larabel wrote [10]. Earlier GCC work on compiling a single file in parallel has still not landed, years later [11].
The absolute time will not carry over to a CI runner. The test rig had 128 cores, 1,536 GB of DDR5-6400 across 24 modules and a PCIe Gen5 SSD, and it did not use a RAMdisk [2][4]. The percentage has a better chance of carrying over. Stoakes' cover-letter result on a dual EPYC 9754 is a cut of about 29% [2], close to Larabel's figure on different EPYC silicon. Larabel wrote that the changes also cut build times proportionally on processors that are not leading edge [13]. Every before-and-after timing in these reports, though, comes from a two-socket EPYC server.
Relative gains shrink as the build grows. The allmodconfig cut is about 21% [3], against about 32% for defconfig [1]. That pattern fits a fixed Kbuild overhead spread over far more compilation. Larabel names bisecting kernel regressions as one use for fast clean builds [16]. For bisects, and for CI that rebuilds after small changes, the closer match is Phoronix's figure of around 70% faster incremental builds [6].
Phoronix's first report on the work said the AI produced a lot of hideous code but found major bottlenecks holding back Linux compilation speed [14]. I think that is a sound way to divide build-system work: the model locates the stalls, and the mailing list decides which code survives. Stoakes has since taken the series through four posted versions [5].
What to watch
- Whether the series is merged for Linux 7.4, as Phoronix expects it may be.
- Before-and-after timings on a desktop or low-core-count machine, which would test the claim that the gains carry over proportionally.
- Phoronix's first EPYC 9686F kernel build run, which would show whether the hardware half of the 10-second forecast holds.