ci: Use a RAM disk for NetBSD and OpenBSD.
authorThomas Munro <tmunro@postgresql.org>
Mon, 3 Mar 2025 22:18:29 +0000 (11:18 +1300)
committerThomas Munro <tmunro@postgresql.org>
Mon, 3 Mar 2025 22:29:21 +0000 (11:29 +1300)
Put the RAM disk setup for all three *BSD CI tasks into a common script,
replacing the old FreeBSD-specific one from commit 0265e5c1.  This makes
them run 3 times and a bit over 2 times faster, respectively.

NetBSD and FreeBSD now share the same one-liner to mount tmpfs.  OpenBSD
needs a GCP-image specific recipe that knows where to steal an unused
disk partition needed to reserve swap space for an mfs RAM disk, because
its tmpfs is deprecated and currently broken.  The configured size is
enough for our current tests but could potentially need future
expansion.  Thanks to Bilal for the disklabel incantation.

Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKGJJ-XrPhN%2BQA4ZUfYAAXcwOSDty9t0vE9Z8__AdacKnQg%40mail.gmail.com

.cirrus.tasks.yml
src/tools/ci/gcp_freebsd_repartition.sh [deleted file]
src/tools/ci/gcp_ram_disk.sh [new file with mode: 0755]

index 91b51142d2ebcba7fc56add2537b0c2124884d57..c5e7b743bfb2088b6ce0386580bcfb41e89b52fd 100644 (file)
@@ -155,8 +155,7 @@ task:
 
   ccache_cache:
     folder: $CCACHE_DIR
-  # Work around performance issues due to 32KB block size
-  repartition_script: src/tools/ci/gcp_freebsd_repartition.sh
+  setup_ram_disk_script: src/tools/ci/gcp_ram_disk.sh
   create_user_script: |
     pw useradd postgres
     chown -R postgres:postgres .
@@ -276,7 +275,7 @@ task:
 
   ccache_cache:
     folder: $CCACHE_DIR
-
+  setup_ram_disk_script: src/tools/ci/gcp_ram_disk.sh
   create_user_script: |
     useradd postgres
     chown -R postgres:users /home/postgres
diff --git a/src/tools/ci/gcp_freebsd_repartition.sh b/src/tools/ci/gcp_freebsd_repartition.sh
deleted file mode 100755 (executable)
index 3adb8fb..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-
-set -e
-set -x
-
-# fix backup partition table after resize
-gpart recover da0
-gpart show da0
-
-# 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/md1 $CIRRUS_WORKING_DIR
-cp -a $CIRRUS_WORKING_DIR.orig/ $CIRRUS_WORKING_DIR/
diff --git a/src/tools/ci/gcp_ram_disk.sh b/src/tools/ci/gcp_ram_disk.sh
new file mode 100755 (executable)
index 0000000..d486345
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+# Move working directory into a RAM disk for better performance.
+
+set -e
+set -x
+
+mv $CIRRUS_WORKING_DIR $CIRRUS_WORKING_DIR.orig
+mkdir $CIRRUS_WORKING_DIR
+
+case "`uname`" in
+  FreeBSD|NetBSD)
+    mount -t tmpfs tmpfs $CIRRUS_WORKING_DIR
+    ;;
+  OpenBSD)
+    umount /dev/sd0j # unused /usr/obj partition
+    printf "m j\n\n\nswap\nw\nq\n" | disklabel -E sd0
+    swapon /dev/sd0j
+    mount -t mfs -o rw,noatime,nodev,-s=8000000 swap $CIRRUS_WORKING_DIR
+    ;;
+esac
+
+cp -a $CIRRUS_WORKING_DIR.orig/. $CIRRUS_WORKING_DIR/