meson: add and use stamp files for generated headers

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Subject: meson: add and use stamp files for generated headers
Date: 2025-08-09 00:05:57
Message-ID: cgkdgvzdpinkacf4v33mky7tbmk467oda5dd4dlmucjjockxzi@xkqfvjoq4uiy
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

As $subject says, I'd like to introduce stamp files for generated headers. The
immediate motivation is that more than half of build.ninja just consists out
of repetitions of the list of generated headers (listed as order-only
dependencies). That makes invocations of ninja a tad slower and makes meson
take a bit longer to generate build.ninja.

Without the change:

andres(at)awork3:/srv/dev/build/postgres/m-master-assert$ wc build.ninja
12713 260280 7754708 build.ninja

andres(at)awork3:/srv/dev/build/postgres/m-master-assert$ numactl --physcpubind 11 time ninja reconfigure
...
3.48user 0.29system 0:03.84elapsed 97%CPU (0avgtext+0avgdata 87640maxresident)k
0inputs+41520outputs (0major+71323minor)pagefaults 0swaps

andres(at)awork3:/srv/dev/build/postgres/m-master-assert$ numactl --physcpubind 11 time ninja
ninja: no work to do.
0.06user 0.03system 0:00.10elapsed 98%CPU (0avgtext+0avgdata 22496maxresident)k
0inputs+0outputs (0major+5216minor)pagefaults 0swaps

With the change:

andres(at)awork3:/srv/dev/build/postgres/m-dev-assert$ wc build.ninja
12733 143627 3376899 build.ninja

andres(at)awork3:/srv/dev/build/postgres/m-dev-assert$ numactl --physcpubind 11 time ninja reconfigure
...
3.14user 0.30system 0:03.53elapsed 97%CPU (0avgtext+0avgdata 74392maxresident)k
0inputs+34576outputs (0major+66026minor)pagefaults 0swaps

andres(at)awork3:/srv/dev/build/postgres/m-dev-assert$ numactl --physcpubind 11 time ninja
ninja: no work to do.
0.04user 0.02system 0:00.06elapsed 100%CPU (0avgtext+0avgdata 19332maxresident)k
0inputs+0outputs (0major+4389minor)pagefaults 0swaps

My main motivation however is not those, in absolute terms, relatively small
speedups, but that I have some patches (LLVM bitcode generation, headerscheck
support, compile_commands.json targets for headers) that add more targets
depending on all those headers, and that the slowdown becomes more noticeable
with those. The improvements with just this patch seems a sufficient
improvement on its own, though - hence this thread.

It's a bit sad to use python to create the stamp files, it's more than 3x
slower than using 'touch' - but touch doesn't work on windows. It's also very
hard to imagine a case where creating stamp files is a significant bottleneck,
given that e.g. genbki.pl is somewhat expensive.

Greetings,

Andres Freund

Attachment Content-Type Size
v2-0001-meson-add-and-use-stamp-files-for-generated-heade.patch text/x-diff 5.4 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2025-08-09 00:25:40 Re: Adding basic NUMA awareness
Previous Message Andres Freund 2025-08-08 23:47:13 Re: index prefetching