Autogenerate some wait events code and documentation

From: "Drouvot, Bertrand" <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Autogenerate some wait events code and documentation
Date: 2023-03-29 09:44:39
Message-ID: 77a86b3a-c4a8-5f5d-69b9-d70bbf2e9b98@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

In another thread [1], Thomas had the idea to $SUBJECT in a similar way
to what is currently done with src/backend/storage/lmgr/lwlocknames.txt.

Doing so, like in the attached patch proposal, would help to avoid:

- wait event without documentation like observed in [2]
- orphaned wait event like observed in [3]

The patch relies on a new src/backend/utils/activity/waiteventnames.txt file that contains on row
per wait event, with this format:

<ENUM NAME> <WAIT EVENT ENUM> <WAIT EVENT NAME> <WAIT EVENT DOC SENTENCE>

Then, a new perl script (src/backend/utils/activity/generate-waiteventnames.pl) generates the new:

- waiteventnames.c
- waiteventnames.h
- waiteventnames.sgml

files.

Remarks:

- The new src/backend/utils/activity/waiteventnames.txt file has been created with (a quickly written, non polished
and not part of the patch) generate_waiteventnames_txt.sh script attached. Then, the proposal for the 2 wait events
missing documentation (non committed yet) done in [2] has been added manually to waiteventnames.txt.

- The patch does take care of wait events that currently are linked to enums, means:

- PG_WAIT_ACTIVITY
- PG_WAIT_CLIENT
- PG_WAIT_IPC
- PG_WAIT_TIMEOUT
- PG_WAIT_IO

so that PG_WAIT_LWLOCK, PG_WAIT_LOCK, PG_WAIT_BUFFER_PIN and PG_WAIT_EXTENSION are not autogenerated.

This result to having the wait event part of the documentation "monitoring-stats" not ordered as compared to the "Wait Event Types" Table.

This is due to the fact that the new waiteventnames.sgml that contains the documentation for
the autogenerated ones listed above is "included" into doc/src/sgml/monitoring.sgml and then breaks the alphabetical ordering
with the ones not autogenerated.

To fix this I've in mind to also autogenerate enums for PG_WAIT_BUFFER_PIN and PG_WAIT_EXTENSION and
split the current documentation "Wait Event Types" Table in 2 tables: one for the autogenerated ones and one (then for
PG_WAIT_LWLOCK, PG_WAIT_LOCK) for the non autogenerated "lock" related ones.

Looking forward to your feedback,

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

[1]: https://www.postgresql.org/message-id/CA%2BhUKG%2BewEpxm%3DhPNXyupRUB_SKGh-6tO86viaco0g-P_pm_Cw%40mail.gmail.com
[2]: https://www.postgresql.org/message-id/CA%2BhUKGJixAHc860Ej9Qzd_z96Z6aoajAgJ18bYfV3Lfn6t9%3D%2BQ%40mail.gmail.com
[3]: https://www.postgresql.org/message-id/CA%2BhUKGK6tqm59KuF1z%2Bh5Y8fsWcu5v8%2B84kduSHwRzwjB2aa_A%40mail.gmail.com

Attachment Content-Type Size
v1-0001-Generating-waiteventnames.h-waiteventnames.c-and-.patch text/plain 90.7 KB
generate_waiteventnames_txt.sh application/x-sh 1.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2023-03-29 09:51:10 Re: logical decoding and replication of sequences, take 2
Previous Message Aleksander Alekseev 2023-03-29 09:32:39 Re: XID formatting and SLRU refactorings (was: Add 64-bit XIDs into PostgreSQL 15)