Thread (14 messages) 14 messages, 2 authors, 4d ago

[PATCH 1/7] meson: avoid recompiling HTTP sources several times

COOLING4d

From: Patrick Steinhardt <hidden>
Date: 2026-09-24 14:09:22
Subsystem: the rest · Maintainer: Linus Torvalds

We only link curl into a subset of our subcommands. Consequently, as
both "http.c" and "http-walker.c" depend on curl, we don't compile these
into "libgit.a" but instead only link those into the commands that
depend on curl.

In Meson, we wire these dependencies into the target executables by
using the `sources:` keyword. But this has the consequence that we're
recompiling those multiple several times, once for every different
command they are linked into. In fact, each of these sources is compiled
seven times, which of course has an impact on compilation speed.

Fix this issue by instead linking these into a static library so that
they only need to be compiled once. This gives us an almost 10% speedup
in a clean build:

  Benchmark 1: meson compile (version = HEAD~)
    Time (mean ± σ):      6.781 s ±  0.052 s    [User: 100.775 s, System: 22.954 s]
    Range (min … max):    6.709 s …  6.867 s    10 runs

  Benchmark 2: meson compile (version = HEAD)
    Time (mean ± σ):      6.274 s ±  0.021 s    [User: 91.882 s, System: 22.092 s]
    Range (min … max):    6.242 s …  6.306 s    10 runs

  Summary
    meson compile (version = HEAD) ran
      1.08 ± 0.01 times faster than meson compile (version = HEAD~)

Signed-off-by: Patrick Steinhardt <redacted>
---
 meson.build | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/meson.build b/meson.build
index 0a95d90d21..4fdb4c5405 100644
--- a/meson.build
+++ b/meson.build
@@ -1925,10 +1925,13 @@ bin_wrappers += executable('scalar',
 
 if curl.found()
   libgit_curl = declare_dependency(
-    sources: [
-      'http.c',
-      'http-walker.c',
-    ],
+    link_with: static_library('git-curl',
+      sources: [
+        'http.c',
+        'http-walker.c',
+      ],
+      dependencies: [libgit_commonmain, curl],
+    ),
     dependencies: [libgit_commonmain, curl],
   )
 
-- 
2.56.0.rc2.329.gd58861e689.dirty
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help