From a205efd900f297736d33a47358b8f332913be506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Mon, 2 Jan 2023 16:30:21 +0100 Subject: [PATCH] Meta: Generate manpages for website in parallel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pandoc is a single-threaded and pretty slow application, so we can run it in the background and "synchronize" before generating section indices. Timing results: Before: Time (abs ≡): 59.833 s [User: 49.541 s, System: 6.943 s] After: Time (abs ≡): 20.440 s [User: 133.928 s, System: 12.290 s] (both generated with hyperfine -p "rm -r output || true" -r 1 Meta/build-manpages-website.sh ) --- Meta/build-manpages-website.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Meta/build-manpages-website.sh b/Meta/build-manpages-website.sh index 6931cd8efd..e17c432190 100755 --- a/Meta/build-manpages-website.sh +++ b/Meta/build-manpages-website.sh @@ -44,9 +44,13 @@ for md_file in $(find "${MAN_DIR}" -iname '*.md' | ${SORT}); do --lua-filter=Meta/convert-markdown-links.lua \ --metadata title="${name}(${section_number}) - SerenityOS man pages" \ -o "${output_file}" \ - "${md_file}" + "${md_file}" & done +# Wait for all pandoc executions to finish so that man page indices are always correct. +# shellcheck disable=SC2046 # Word splitting is intentional here +wait $(jobs -p) + # Generate man page listings through pandoc for section_directory in output/*/; do section=$(basename "${section_directory}") @@ -78,7 +82,7 @@ for section_directory in output/*/; do fi echo "- [${name}](${filename})" done - ) + ) & done # Generate main landing page listings through pandoc @@ -87,12 +91,12 @@ pandoc -f gfm -t html5 -s \ -B Meta/Websites/man.serenityos.org/banner-preamble.inc \ --metadata title="SerenityOS man pages" \ -o output/index.html \ - Meta/Websites/man.serenityos.org/index.md + Meta/Websites/man.serenityos.org/index.md & pandoc -f gfm -t html5 -s \ -B Meta/Websites/man.serenityos.org/banner-preamble.inc \ --metadata title="Can't run applications" \ -o output/cant-run-application.html \ - Meta/Websites/man.serenityos.org/cant-run-application.md + Meta/Websites/man.serenityos.org/cant-run-application.md & # Copy pre-made files echo 'Copying images' @@ -108,3 +112,6 @@ while read -r p; do done < icons.txt rm icons.txt + +# shellcheck disable=SC2046 # Word splitting is intentional here +wait $(jobs -p)