git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Patrick Steinhardt <ps@pks.im>
Date
Sep 24, 2026, 14:09 UTC
Message-ID
<20260924-pks-meson-improvements-v1-1-90b7f79f1c4e@pks.im>
In-Reply-To
<20260924-pks-meson-improvements-v1-0-90b7f79f1c4e@pks.im>

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 <ps@pks.im>
---
 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
Previous: Patrick SteinhardtNext: Karthik Nayak
Message 2 of 20 in “A couple of Meson improvements”
  1. 0/7 A couple of Meson improvementsPatrick Steinhardt, Sep 24, 2026
  2. 1/7 meson: avoid recompiling HTTP sources several timesPatrick Steinhardt, Sep 24, 2026
  3. Karthik NayakSep 30, 2026
  4. Kaartic SivaraamOct 5, 2026
  5. 2/7 meson: don't recompile git-remote-http(1) multiple times for testsPatrick Steinhardt, Sep 24, 2026
  6. 3/7 meson: use precompiled headers for our test-helperPatrick Steinhardt, Sep 24, 2026
  7. Karthik NayakSep 30, 2026
  8. 4/7 meson: use precompiled headers for unit testsPatrick Steinhardt, Sep 24, 2026
  9. Kaartic SivaraamOct 5, 2026
  10. Patrick SteinhardtOct 5, 2026
  11. 5/7 meson: fix outdated completion helpersPatrick Steinhardt, Sep 24, 2026
  12. 6/7 meson: update wrappersPatrick Steinhardt, Sep 24, 2026
  13. Karthik NayakSep 30, 2026
  14. Kaartic SivaraamOct 5, 2026
  15. Patrick SteinhardtOct 5, 2026
  16. 7/7 gitlab-ci: fix hanging MSVC jobsPatrick Steinhardt, Sep 24, 2026
  17. Karthik NayakSep 30, 2026
  18. Patrick SteinhardtSep 30, 2026
  19. Karthik NayakSep 30, 2026
  20. Kaartic SivaraamOct 5, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.