Skip to content

Commit 93e4f79

Browse files
committed
install_prereq.sh: Build more of the prereqs in parallel.
Speed up the bottleneck builds in the CI by building in parallel several of the most time-consuming to build libraries. The containers used by the GitHub CI have 4 cores, and the prereq install phase can be sped up non-trivially by doing this. Benchmarking the total time to run install_prereq.sh (on Debian systems where all the packages have already been installed), compiling libdiscord, libetpan, and libopenarc in parallel cuts the script execution time almost in half. Even though using -j$(nproc) across 3 scripts theoretically results in 12 threads running on a system with only 4 cores, this still yielded better performance than just running in parallel alone, so all three scripts now use -j$(nproc) in addition to being run in parallel. This yields greater user time but the lowest wall clock time overall. All systems running any of the scripts alone will benefit from the -j$(nproc), but in practice, all 3 libraries are only supported on Debian-based distros, so only Debian-based systems will realize the overall speedup. (AWS t3.xlarge, 4 vCPU, 16 GB - same specs as a GitHub CI runner): Serial, without -j$(nproc): real 2m32.726s user 2m8.945s sys 0m27.937s Serial, with -j$(nproc): real 1m44.368s user 2m27.967s sys 0m28.350s Parallel, without -j$(nproc): real 1m50.111s user 2m15.002s sys 0m26.602s Parallel, with -j$(nproc): real 1m12.970s user 2m40.010s sys 0m27.909s (AWS t3.small, 2 vCPU, 2 GB of RAM): Serial compilation, without -j$(nproc, except in libdiscord.sh: real 2m27.488s user 2m5.345s sys 0m20.269s Parallel, without -j$(nproc, except in libdiscord.sh: real 1m53.429s user 2m16.722s sys 0m20.528s Parallel, and with -j$(nproc): real 1m41.834s user 2m41.015s sys 0m24.475s
1 parent 67678fe commit 93e4f79

File tree

3 files changed

+35
-29
lines changed

3 files changed

+35
-29
lines changed

scripts/install_prereq.sh

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ PACKAGES_DEBIAN="$PACKAGES_DEBIAN bc"
196196
PACKAGES_DEBIAN="$PACKAGES_DEBIAN html2text"
197197
# INSTALL_LIBETPAN=0 on Fedora-based systems, so don't bother installing html2text on those.
198198

199+
# doxygen only: env var required to enable
200+
if [ "$INCLUDE_DOXYGEN" = "1" ]; then
201+
PACKAGES_DEBIAN="$PACKAGES_DEBIAN doxygen graphviz"
202+
fi
203+
199204
# Required only for tests
200205
if [ "$1" = "1" ]; then
201206
# mariadb-server is required for some of the test modules (test_auth_mysql, test_irc_chanserv)
@@ -306,34 +311,35 @@ scripts/libwss.sh
306311
# mod_slack (also depends on libwss)
307312
scripts/libslackrtm.sh
308313

309-
# libdiscord (mod_discord)
310-
if [ "$INSTALL_LIBDISCORD" != "0" ]; then
311-
# Makefile doesn't add the proper LDFLAGS on BSD and doesn't seem to obey LDFLAGS when passed in...
312-
scripts/libdiscord.sh
313-
fi
314-
315-
# libetpan fails to build successfully on Fedora-based distros,
316-
# so need to be able to skip that for now using an env var.
317-
if [ "$INSTALL_LIBETPAN" != "0" ]; then
318-
# libetpan (mod_webmail): the package no longer suffices, since we patch the source.
319-
#PACKAGES_DEBIAN="$PACKAGES_DEBIAN libetpan-dev"
320-
scripts/libetpan.sh
321-
322-
# evergreen (door_evergreen)
323-
scripts/evergreen.sh
314+
if [ "$INSTALL_LIBDISCORD" != "0" ] && [ "$INSTALL_LIBETPAN" != "0" ] && [ "$INSTALL_LIBOPENARC" != "0" ]; then
315+
# On machines with many CPU cores, take advantage of the parallelism available by building several libraries at once
316+
printf "Building libdiscord, libetpan, and libopenarc in parallel\n"
317+
(trap 'kill 0' INT; scripts/libdiscord.sh & (scripts/libetpan.sh && scripts/evergreen.sh) & scripts/libopenarc.sh & wait)
324318
else
325-
printf "Skipping libetpan install (INSTALL_LIBETPAN=%s)\n" "$INSTALL_LIBETPAN"
326-
fi
319+
# libdiscord (mod_discord)
320+
if [ "$INSTALL_LIBDISCORD" != "0" ]; then
321+
# Makefile doesn't add the proper LDFLAGS on BSD and doesn't seem to obey LDFLAGS when passed in...
322+
scripts/libdiscord.sh
323+
fi
327324

328-
# mod_smtp_filter_arc
329-
# milter pre-req can be hard to satisfy, so can be disabled using an env var
330-
if [ "$INSTALL_LIBOPENARC" != "0" ]; then
331-
scripts/libopenarc.sh
332-
else
333-
printf "Skipping libopenarc install (INSTALL_LIBOPENARC=%s)\n" "$INSTALL_LIBOPENARC"
334-
fi
325+
# libetpan fails to build successfully on Fedora-based distros,
326+
# so need to be able to skip that for now using an env var.
327+
if [ "$INSTALL_LIBETPAN" != "0" ]; then
328+
# libetpan (mod_webmail): the package no longer suffices, since we patch the source.
329+
#PACKAGES_DEBIAN="$PACKAGES_DEBIAN libetpan-dev"
330+
scripts/libetpan.sh
335331

336-
# doxygen only: env var required to enable
337-
if [ "$INCLUDE_DOXYGEN" = "1" ]; then
338-
PACKAGES_DEBIAN="$PACKAGES_DEBIAN doxygen graphviz"
332+
# evergreen (door_evergreen)
333+
scripts/evergreen.sh
334+
else
335+
printf "Skipping libetpan install (INSTALL_LIBETPAN=%s)\n" "$INSTALL_LIBETPAN"
336+
fi
337+
338+
# mod_smtp_filter_arc
339+
# milter pre-req can be hard to satisfy, so can be disabled using an env var
340+
if [ "$INSTALL_LIBOPENARC" != "0" ]; then
341+
scripts/libopenarc.sh
342+
else
343+
printf "Skipping libopenarc install (INSTALL_LIBOPENARC=%s)\n" "$INSTALL_LIBOPENARC"
344+
fi
339345
fi

scripts/libetpan.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ wget "https://patch-diff.githubusercontent.com/raw/dinhvh/libetpan/pull/447.diff
3030
git apply 447.diff
3131

3232
./autogen.sh --with-poll
33-
make
33+
make -j$(nproc)
3434
make install

scripts/libopenarc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ else
1111
fi
1212
git checkout develop # master branch is behind
1313
# https://github.com/trusteddomainproject/OpenARC/issues/118
14-
aclocal && autoconf && autoreconf --install && automake --add-missing && ./configure && make all
14+
aclocal && autoconf && autoreconf --install && automake --add-missing && ./configure && make all -j$(nproc)
1515
make install

0 commit comments

Comments
 (0)