Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fa88928

Browse filesBrowse files
committed
Generate automatically code and documentation related to wait events
The documentation and the code is generated automatically from a new file called wait_event_names.txt, formatted in sections dedicated to each wait event class (Timeout, Lock, IO, etc.) with three tab-separated fields: - C symbol in enums - Format in the system views - Description in the docs Using this approach has several advantages, as we have proved to be rather bad in maintaining this area of the tree across the years: - The order of each item in the documentation and the code, which should be alphabetical, has become incorrect multiple times, and the script generating the code and documentation has a few rules to enforce that, making the maintenance a no-brainer. - Some wait events were added to the code, but not documented, so this cannot be missed now. - The order of the tables for each wait event class is enforced in the documentation (the input .txt file does so as well for clarity, though this is not mandatory). - Less code, shaving 1.2k lines from the tree, with 1/3 of the savings coming from the code, the rest from the documentation. The wait event types "Lock" and "LWLock" still have their own code path for their code, hence only the documentation is created for them. These classes are listed with a special marker called WAIT_EVENT_DOCONLY in the input file. Adding a new wait event now requires only an update of wait_event_names.txt, with "Lock" and "LWLock" treated as exceptions. This commit has been tested with configure/Makefile, the CI and VPATH build. clean, distclean and maintainer-clean were working fine. Author: Bertrand Drouvot, Michael Paquier Discussion: https://postgr.es/m/77a86b3a-c4a8-5f5d-69b9-d70bbf2e9b98@gmail.com
1 parent 48efb23 commit fa88928
Copy full SHA for fa88928

22 files changed

+757
-2111
lines changed

‎doc/src/sgml/.gitignore

Copy file name to clipboardExpand all lines: doc/src/sgml/.gitignore
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/errcodes-table.sgml
1818
/keywords-table.sgml
1919
/version.sgml
20+
/wait_event_types.sgml
2021
# Assorted byproducts from building the above
2122
/postgres-full.xml
2223
/INSTALL.html

‎doc/src/sgml/Makefile

Copy file name to clipboardExpand all lines: doc/src/sgml/Makefile
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ override XSLTPROCFLAGS += --stringparam pg.version '$(VERSION)'
5858

5959
GENERATED_SGML = version.sgml \
6060
features-supported.sgml features-unsupported.sgml errcodes-table.sgml \
61-
keywords-table.sgml
61+
keywords-table.sgml wait_event_types.sgml
6262

6363
ALLSGML := $(wildcard $(srcdir)/*.sgml $(srcdir)/ref/*.sgml) $(GENERATED_SGML)
6464

@@ -111,6 +111,8 @@ errcodes-table.sgml: $(top_srcdir)/src/backend/utils/errcodes.txt generate-errco
111111
keywords-table.sgml: $(top_srcdir)/src/include/parser/kwlist.h $(wildcard $(srcdir)/keywords/sql*.txt) generate-keywords-table.pl
112112
$(PERL) $(srcdir)/generate-keywords-table.pl $(srcdir) > $@
113113

114+
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
115+
$(PERL) $(top_srcdir)/src/backend/utils/activity/generate-wait_event_types.pl --docs $<
114116

115117
##
116118
## Generation of some text files.

‎doc/src/sgml/filelist.sgml

Copy file name to clipboardExpand all lines: doc/src/sgml/filelist.sgml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<!ENTITY maintenance SYSTEM "maintenance.sgml">
4343
<!ENTITY manage-ag SYSTEM "manage-ag.sgml">
4444
<!ENTITY monitoring SYSTEM "monitoring.sgml">
45+
<!ENTITY wait_event_types SYSTEM "wait_event_types.sgml">
4546
<!ENTITY regress SYSTEM "regress.sgml">
4647
<!ENTITY runtime SYSTEM "runtime.sgml">
4748
<!ENTITY config SYSTEM "config.sgml">

‎doc/src/sgml/meson.build

Copy file name to clipboardExpand all lines: doc/src/sgml/meson.build
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ doc_generated += custom_target('errcodes-table.sgml',
4646
capture: true,
4747
)
4848

49+
doc_generated += custom_target('wait_event_types.sgml',
50+
input: files(
51+
'../../../src/backend/utils/activity/wait_event_names.txt'),
52+
output: 'wait_event_types.sgml',
53+
command: [perl,
54+
files('../../../src/backend/utils/activity/generate-wait_event_types.pl'),
55+
'--outdir', '@OUTDIR@', '--docs', '@INPUT@'],
56+
build_by_default: false,
57+
install: false,
58+
capture: false,
59+
)
60+
4961
# FIXME: this actually has further inputs, adding depfile support to
5062
# generate-keywords-table.pl is probably the best way to address that
5163
# robustly.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.