From: Patrick Steinhardt <ps@pks.im>
To: phillip.wood@dunelm.org.uk
Cc: git@vger.kernel.org
Subject: Re: [PATCH 8/8] meson: precompile "git-compat-util.h"
Date: Thu, 12 Mar 2026 07:21:51 +0100 [thread overview]
Message-ID: <abJbf3m-EpYmHiYG@pks.im> (raw)
In-Reply-To: <040296b2-9a69-4603-9a2a-2001c98220b7@gmail.com>
On Wed, Mar 11, 2026 at 02:32:36PM +0000, Phillip Wood wrote:
> On 10/03/2026 17:52, Patrick Steinhardt wrote:
> > 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 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~)
>
> This is a nice speedup for a full build. I'm not sure about dumping the
> precompiled header in tools/ though, it seems like an odd location for a
> header file. It is a requirement of meson that the source for the
> precompiled header lives in a separate directory to the rest of the sources
> but it might be better to adopt the suggestion in the documentation of a
> "pch" (or maybe "precompiled"?) directory rather than mixing it in with our
> build scripts.
Yeah, it's a bit on the odd side. The reason I decided on "tools/"
though is that it now contains our build infra and developer tooling, so
it's an okayish fit. And I didn't feel like creating a directory for a
single file, only.
Patrick
next prev parent reply other threads:[~2026-03-12 6:21 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 17:52 [PATCH 0/8] Some build system improvements Patrick Steinhardt
2026-03-10 17:52 ` [PATCH 1/8] Introduce new "tools/" directory Patrick Steinhardt
2026-03-10 17:52 ` [PATCH 2/8] contrib: move "coccinelle/" directory into "tools/" Patrick Steinhardt
2026-03-10 17:52 ` [PATCH 3/8] contrib: move "coverage-diff.sh" script " Patrick Steinhardt
2026-03-10 17:52 ` [PATCH 4/8] contrib: move "update-unicode.sh" " Patrick Steinhardt
2026-03-10 17:52 ` [PATCH 5/8] builds: move build scripts " Patrick Steinhardt
2026-03-10 17:52 ` [PATCH 6/8] git-compat-util.h: move warning infra to prepare for PCHs Patrick Steinhardt
2026-03-10 17:52 ` [PATCH 7/8] meson: compile compatibility sources separately Patrick Steinhardt
2026-03-11 14:32 ` Phillip Wood
2026-03-11 14:56 ` Phillip Wood
2026-03-11 23:27 ` SZEDER Gábor
2026-03-12 6:21 ` Patrick Steinhardt
2026-03-13 10:33 ` Phillip Wood
2026-03-16 8:09 ` Patrick Steinhardt
2026-04-10 15:17 ` SZEDER Gábor
2026-03-12 6:22 ` Patrick Steinhardt
2026-03-13 10:33 ` Phillip Wood
2026-03-16 8:09 ` Patrick Steinhardt
2026-03-16 10:52 ` Phillip Wood
2026-03-17 15:38 ` Kristoffer Haugsbakk
2026-03-19 5:32 ` Patrick Steinhardt
2026-03-10 17:52 ` [PATCH 8/8] meson: precompile "git-compat-util.h" Patrick Steinhardt
2026-03-11 14:32 ` Phillip Wood
2026-03-12 6:21 ` Patrick Steinhardt [this message]
2026-03-10 18:23 ` [PATCH 0/8] Some build system improvements Junio C Hamano
2026-03-11 7:32 ` Patrick Steinhardt
2026-03-13 22:21 ` Junio C Hamano
2026-03-16 8:09 ` Patrick Steinhardt
2026-03-16 10:07 ` [PATCH v2 " Patrick Steinhardt
2026-03-16 10:07 ` [PATCH v2 1/8] Introduce new "tools/" directory Patrick Steinhardt
2026-03-16 10:07 ` [PATCH v2 2/8] contrib: move "coccinelle/" directory into "tools/" Patrick Steinhardt
2026-03-16 10:07 ` [PATCH v2 3/8] contrib: move "coverage-diff.sh" script " Patrick Steinhardt
2026-03-16 10:07 ` [PATCH v2 4/8] contrib: move "update-unicode.sh" " Patrick Steinhardt
2026-03-16 10:08 ` [PATCH v2 5/8] builds: move build scripts " Patrick Steinhardt
2026-03-16 10:08 ` [PATCH v2 6/8] git-compat-util.h: move warning infra to prepare for PCHs Patrick Steinhardt
2026-03-16 10:08 ` [PATCH v2 7/8] meson: compile compatibility sources separately Patrick Steinhardt
2026-03-16 10:08 ` [PATCH v2 8/8] meson: precompile "git-compat-util.h" Patrick Steinhardt
2026-03-16 10:54 ` [PATCH v2 0/8] Some build system improvements Phillip Wood
2026-03-19 5:33 ` [PATCH v3 " Patrick Steinhardt
2026-03-19 5:33 ` [PATCH v3 1/8] Introduce new "tools/" directory Patrick Steinhardt
2026-03-19 5:33 ` [PATCH v3 2/8] contrib: move "coccinelle/" directory into "tools/" Patrick Steinhardt
2026-03-19 5:33 ` [PATCH v3 3/8] contrib: move "coverage-diff.sh" script " Patrick Steinhardt
2026-03-20 12:15 ` Toon Claes
2026-03-19 5:33 ` [PATCH v3 4/8] contrib: move "update-unicode.sh" " Patrick Steinhardt
2026-03-19 5:33 ` [PATCH v3 5/8] builds: move build scripts " Patrick Steinhardt
2026-03-19 5:33 ` [PATCH v3 6/8] git-compat-util.h: move warning infra to prepare for PCHs Patrick Steinhardt
2026-03-20 12:34 ` Toon Claes
2026-03-19 5:33 ` [PATCH v3 7/8] meson: compile compatibility sources separately Patrick Steinhardt
2026-03-19 5:33 ` [PATCH v3 8/8] meson: precompile "git-compat-util.h" Patrick Steinhardt
2026-03-20 12:37 ` Toon Claes
2026-04-10 15:36 ` SZEDER Gábor
2026-04-10 15:46 ` Phillip Wood
2026-04-10 16:05 ` SZEDER Gábor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=abJbf3m-EpYmHiYG@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.