Re: Autogenerate some wait events code and documentation

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: "Drouvot, Bertrand" <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Autogenerate some wait events code and documentation
Date: 2023-07-05 01:57:19
Message-ID: ZKTN//NfDeP1egLW@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jul 04, 2023 at 09:34:33AM +0200, Drouvot, Bertrand wrote:
> Yeah, with "capture" set to "false" then ninja alldocs does not error out
> and wait_event_types.sgml gets generated.
>
> I'll look at the extra options --code and --docs.

+wait_event_types.sgml: $(top_srcdir)/src/backend/utils/activity/wait_event_names.txt $(top_srcdir)/src/backend/utils/activity/generate-wait_event_types.pl
+ $(PERL) $(top_srcdir)/src/backend/utils/activity/generate-wait_event_types.pl --docs $< > $@

This is doing the same error as meson in v10, there is no need for
the last part doing the redirection because the script outputs
nothing. Here is the command generated:
make -C doc/src/sgml/ wait_event_types.sgml
'/usr/bin/perl'
../../../src/backend/utils/activity/generate-wait_event_types.pl
--docs ../../../src/backend/utils/activity/wait_event_names.txt >
wait_event_types.sgml

+wait_event_names = custom_target('wait_event_names',
+ input: files('../../backend/utils/activity/wait_event_names.txt'),
+ output: ['wait_event_types.h'],
This one was not completely correct (look at fmgrtab, for example), as
it is missing pgstat_wait_event.c in the output generated. We could
perhaps be more selective with all that, including fmgrtab, but I have
left that out for now. Note also the tweak with install_dir to not
install the C file.

+wait_event_names = custom_target('wait_event_names',
+ input: files('./wait_event_names.txt'),
+ output: ['pgstat_wait_event.c'],
+ command: [
+ perl, files('./generate-wait_event_types.pl'),
+ '-o', '@OUTDIR@', '--code',
+ '@INPUT@'
+ ],
+ install: true,
+ install_dir: [false],
+)
[...]
+# these include .c files generated in ../../../include/activity, seems nicer to not
+# add that as an include path for the whole backend
+waitevent_sources = files(
'wait_event.c',
)
+
+backend_link_with += static_library('wait_event_names',
+ waitevent_sources,
+ dependencies: [backend_code],
+ include_directories: include_directories('../../../include/utils'),
+ kwargs: internal_lib_args,
+)

"wait_event_names" with the extra command should not be necessary
here, because we feed from the C file generated in src/include/utils/,
included in wait_event.c. See src/backend/nodes/meson.build for a
similar example

Two of the error messages after rename() in the script were
inconsistent. So reworded these on the way.

I have added a usage() to the script, while on it.

The VPATH build was broken, because the following line was missing
from src/backend/utils/activity/Makefile to be able to detect
pgstat_wait_event.c from wait_event.c:
override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS)

With all that in place, VPATH builds, the CI, meson, configure/make
and the various cleanup targets were working fine, so I have applied
it. Now let's see what the buildfarm tells.

The final --stat number is like that:
22 files changed, 757 insertions(+), 2111 deletions(-)
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2023-07-05 02:14:52 Re: Initial Schema Sync for Logical Replication
Previous Message Michael Paquier 2023-07-05 01:55:34 pgsql: Generate automatically code and documentation related to wait ev