From: Toon Claes Date: Fri, 20 Mar 2026 12:37:05 GMT Subject: Re: [PATCH v3 8/8] meson: precompile "git-compat-util.h" Message-ID: <87v7eq1xu6.fsf@iotcl.com> In-Reply-To: <20260319-b4-pks-build-infra-improvements-v3-8-82f5fb3edc3f@pks.im> Patrick Steinhardt writes: > Every compilation unit in Git is expected to include "git-compat-util.h" > first, either directly or indirectly via "builtin.h". This header papers > over differences between platforms so that we can expect the typical > POSIX functions to exist. Furthermore, it provides functionality that we > end up using everywhere. > > This header is thus quite heavy as a consequence. Preprocessing it as a > standalone unit via `clang -E git-compat-util.h` yields over 23,000 > lines of code overall. Naturally, it takes quite some time to compile > all of this. > > Luckily, this is exactly the kind of use case that precompiled headers > aim to solve: instead of recompiling it every single time, we compile it > once and then link the result into the executable. If include guards are > set up properly it means that the file won't need to be reprocessed. > > Set up such a precompiled header for "git-compat-util.h" and wire it up > via Meson. This causes Meson to implicitly include the precompiled > header in all compilation units. With GCC and Clang for example this is > done via the "-include" statement [1]. > > This leads to a significant speedup when performing full builds: > > Benchmark 1: ninja (rev = HEAD~) > Time (mean ± σ): 14.467 s ± 0.126 s [User: 248.133 s, System: 31.298 s] > Range (min … max): 14.195 s … 14.633 s 10 runs > > Benchmark 2: ninja (rev = HEAD) > Time (mean ± σ): 10.307 s ± 0.111 s [User: 173.290 s, System: 23.998 s] > Range (min … max): 10.030 s … 10.433 s 10 runs > > Summary > ninja (rev = HEAD) ran > 1.40 ± 0.02 times faster than ninja (rev = HEAD~) > Quite cool! The only nit I would have about this, this optimization is not applied to building with Makefiles. While that isn't an issue, I wouldn't have hurt if it was mentioned in the commit message. Anyway, overall I got nothing that's holding back this series from merging. Looks good! -- Cheers, Toon