From 0265e5c120e0971a9c50a1e27ce4cb847c15a1bf Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Wed, 13 Mar 2024 14:51:24 +1300 Subject: [PATCH] ci: Use a RAM disk and more CPUs on FreeBSD. Run the tests in a RAM disk. It's still a UFS file system and is backed by 20GB of disk, but this avoids a lot of I/O. Even though we disable fsync, our tests do a lot of directory manipulations, some of which force file system meta-data to disk and flush slow device write caches on UFS. This was a bottleneck preventing effective scaling beyond 2 CPUs. Now we can use 4 CPUs like on other OSes, for a huge speedup. Reviewed-by: Maxim Orlov Discussion: https://postgr.es/m/CA%2BhUKG%2BFXLcEg1dyTqJjDiNQ8pGom4KrJj4wF38C90thti9dVA%40mail.gmail.com --- .cirrus.tasks.yml | 8 +++---- src/tools/ci/gcp_freebsd_repartition.sh | 28 ++++++++++++------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/.cirrus.tasks.yml b/.cirrus.tasks.yml index 3b5b54df58..1adfdfdd45 100644 --- a/.cirrus.tasks.yml +++ b/.cirrus.tasks.yml @@ -126,11 +126,9 @@ task: name: FreeBSD - 13 - Meson env: - # FreeBSD on GCP is slow when running with larger number of CPUS / - # jobs. Using one more job than cpus seems to work best. - CPUS: 2 - BUILD_JOBS: 3 - TEST_JOBS: 3 + CPUS: 4 + BUILD_JOBS: 4 + TEST_JOBS: 8 IMAGE_FAMILY: pg-ci-freebsd-13 DISK_SIZE: 50 diff --git a/src/tools/ci/gcp_freebsd_repartition.sh b/src/tools/ci/gcp_freebsd_repartition.sh index 2d5e173899..cc7f6bc35e 100755 --- a/src/tools/ci/gcp_freebsd_repartition.sh +++ b/src/tools/ci/gcp_freebsd_repartition.sh @@ -3,26 +3,24 @@ set -e set -x -# The default filesystem on freebsd gcp images is very slow to run tests on, -# due to its 32KB block size -# -# XXX: It'd probably better to fix this in the image, using something like -# https://people.freebsd.org/~lidl/blog/re-root.html - # fix backup partition table after resize gpart recover da0 gpart show da0 -# kill swap, so we can delete a partition -swapoff -a || true -# (apparently we can only have 4!?) -gpart delete -i 3 da0 -gpart add -t freebsd-ufs -l data8k -a 4096 da0 -gpart show da0 -newfs -U -b 8192 /dev/da0p3 -# Migrate working directory +# delete and re-add swap partition with expanded size +swapoff -a +gpart delete -i 3 da0 +gpart add -t freebsd-swap -l swapfs -a 4096 da0 +gpart show da0 +swapon -a + +# create a file system on a memory disk backed by swap, to minimize I/O +mdconfig -a -t swap -s20g -u md1 +newfs -b 8192 -U /dev/md1 + +# migrate working directory du -hs $CIRRUS_WORKING_DIR mv $CIRRUS_WORKING_DIR $CIRRUS_WORKING_DIR.orig mkdir $CIRRUS_WORKING_DIR -mount -o noatime /dev/da0p3 $CIRRUS_WORKING_DIR +mount -o noatime /dev/md1 $CIRRUS_WORKING_DIR cp -r $CIRRUS_WORKING_DIR.orig/* $CIRRUS_WORKING_DIR/