diff --git a/.github/actions/test-go-pg/action.yaml b/.github/actions/test-go-pg/action.yaml index fb33ba649f5..b973277825a 100644 --- a/.github/actions/test-go-pg/action.yaml +++ b/.github/actions/test-go-pg/action.yaml @@ -50,13 +50,38 @@ inputs: runs: using: "composite" steps: + - name: Mount tmpfs for Go temp dir (Linux) + if: runner.os == 'Linux' + shell: bash + run: | + # GOTMPDIR holds test binaries and t.TempDir() output. Keep them off + # the EBS-backed root disk like the Windows and macOS RAM disks do. + if [[ -z "${GOTMPDIR:-}" ]]; then + echo "GOTMPDIR is not set, skipping" + exit 0 + fi + mkdir -p "${GOTMPDIR}" + sudo mount -t tmpfs -o size=8g tmpfs "${GOTMPDIR}" + - name: Start PostgreSQL Docker container (Linux) if: runner.os == 'Linux' shell: bash env: POSTGRES_VERSION: ${{ inputs.postgres-version }} + TEST_POSTGRES_LOG_STATEMENT: none run: make test-postgres-docker + - name: Start I/O sampler (Linux) + if: runner.os == 'Linux' + shell: bash + run: | + nohup vmstat -t 1 > "${RUNNER_TEMP}/vmstat.log" 2>&1 & + echo $! > "${RUNNER_TEMP}/vmstat.pid" + if command -v iostat > /dev/null; then + nohup iostat -dxt 1 > "${RUNNER_TEMP}/iostat.log" 2>&1 & + echo $! > "${RUNNER_TEMP}/iostat.pid" + fi + - name: Setup Embedded Postgres (Windows/macOS) if: runner.os != 'Linux' shell: bash @@ -102,3 +127,23 @@ runs: else make test fi + + - name: Stop I/O sampler (Linux) + if: always() && runner.os == 'Linux' + shell: bash + run: | + for name in vmstat iostat; do + pidfile="${RUNNER_TEMP}/${name}.pid" + [[ -f "${pidfile}" ]] && kill "$(cat "${pidfile}")" 2> /dev/null || true + done + + - name: Upload I/O samples (Linux) + if: failure() && runner.os == 'Linux' + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: io-samples-${{ github.job }} + path: | + ${{ runner.temp }}/vmstat.log + ${{ runner.temp }}/iostat.log + if-no-files-found: ignore + retention-days: 7 diff --git a/Makefile b/Makefile index 1328d0a644c..879d0799a68 100644 --- a/Makefile +++ b/Makefile @@ -218,6 +218,8 @@ VERSION := $(shell ./scripts/version.sh) POSTGRES_VERSION ?= 17 POSTGRES_IMAGE ?= us-docker.pkg.dev/coder-v2-images-public/public/postgres:$(POSTGRES_VERSION) +# CI test jobs set this to "none": nothing reads the statement log there. +TEST_POSTGRES_LOG_STATEMENT ?= all # Limit parallel Make jobs in pre-commit/pre-push. Defaults to # nproc/4 (min 2) since test, lint, and build targets have internal @@ -1683,7 +1685,7 @@ test-postgres-docker: -c fsync=off \ -c synchronous_commit=off \ -c full_page_writes=off \ - -c log_statement=all + -c log_statement=$(TEST_POSTGRES_LOG_STATEMENT) while ! pg_isready -h 127.0.0.1 do echo "$$(date) - waiting for database to start"