From 2aeab722bc2e506fc043ad5507c751c4752be6ef Mon Sep 17 00:00:00 2001 From: Jason Little Date: Fri, 2 Dec 2022 06:24:39 -0600 Subject: [PATCH 1/5] Mount Postgresql's data directory on a tmpfs in-memory filesystem. This covers two topics. 1. Removes using docker's overlayfs filesystem driver. 2. Uses the linux tmpfs, which uses much simpler structures with much lower overhead than a traditional filesystem. --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4cb2459b37a8..f61d5e666b00 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -197,8 +197,10 @@ jobs: - run: sudo apt-get -qq install xmlsec1 - name: Set up PostgreSQL ${{ matrix.job.postgres-version }} if: ${{ matrix.job.postgres-version }} + # 1. Mount postgres data files onto a tmpfs in-memory filesystem to reduce overhead of docker's overlayfs layer. run: | docker run -d -p 5432:5432 \ + --tmpfs /var/lib/postgres:rw,size=6144m \ -e POSTGRES_PASSWORD=postgres \ -e POSTGRES_INITDB_ARGS="--lc-collate C --lc-ctype C --encoding UTF8" \ postgres:${{ matrix.job.postgres-version }} From dc44cf3bc0f34dc4f245b2faffa28b600bf03c36 Mon Sep 17 00:00:00 2001 From: Jason Little Date: Fri, 2 Dec 2022 06:53:02 -0600 Subject: [PATCH 2/5] Expose Postgresql unix socket, and wire it up to SYNAPSE_POSTGRES_HOST. This allows reducing latency by not using the docker-proxy service for network connections. --- .github/workflows/tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f61d5e666b00..f2cbaa047fa9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -198,9 +198,11 @@ jobs: - name: Set up PostgreSQL ${{ matrix.job.postgres-version }} if: ${{ matrix.job.postgres-version }} # 1. Mount postgres data files onto a tmpfs in-memory filesystem to reduce overhead of docker's overlayfs layer. + # 2. Expose the unix socket for postgres. This removes latency of using docker-proxy for connections. run: | docker run -d -p 5432:5432 \ --tmpfs /var/lib/postgres:rw,size=6144m \ + --mount 'type=bind,src=/var/run/postgresql,dst=/var/run/postgresql' \ -e POSTGRES_PASSWORD=postgres \ -e POSTGRES_INITDB_ARGS="--lc-collate C --lc-ctype C --encoding UTF8" \ postgres:${{ matrix.job.postgres-version }} @@ -225,7 +227,7 @@ jobs: - run: poetry run trial --jobs=2 tests env: SYNAPSE_POSTGRES: ${{ matrix.job.database == 'postgres' || '' }} - SYNAPSE_POSTGRES_HOST: localhost + SYNAPSE_POSTGRES_HOST: /var/run/postgresql SYNAPSE_POSTGRES_USER: postgres SYNAPSE_POSTGRES_PASSWORD: postgres - name: Dump logs From b8cf5a9f378c2540903ef79978d7907d4ab6c987 Mon Sep 17 00:00:00 2001 From: Jason Little Date: Fri, 2 Dec 2022 17:31:23 -0600 Subject: [PATCH 3/5] Saturate the vCpu on Github for test. In some(quick, eyeball) testing on my machine(using htop), I noticed that when given the number of jobs for same number of Cpus, most of the time a given Cpu was only using a third of it's potential. --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f2cbaa047fa9..9a5c687edb22 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -224,7 +224,7 @@ jobs: if: ${{ matrix.job.postgres-version }} timeout-minutes: 2 run: until pg_isready -h localhost; do sleep 1; done - - run: poetry run trial --jobs=2 tests + - run: poetry run trial --jobs=6 tests env: SYNAPSE_POSTGRES: ${{ matrix.job.database == 'postgres' || '' }} SYNAPSE_POSTGRES_HOST: /var/run/postgresql From 382f43d5bc0fbe00a4c3bffebc5513cb6756b4bf Mon Sep 17 00:00:00 2001 From: Jason Little Date: Sat, 3 Dec 2022 04:28:25 -0600 Subject: [PATCH 4/5] Changelog --- changelog.d/14610.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/14610.misc diff --git a/changelog.d/14610.misc b/changelog.d/14610.misc new file mode 100644 index 000000000000..097bf41acab2 --- /dev/null +++ b/changelog.d/14610.misc @@ -0,0 +1 @@ +Alter some unit test environment parameters to decrease time spent running tests. From 2977986720b0add178e228e9bc198b5ffaae4279 Mon Sep 17 00:00:00 2001 From: Jason Little Date: Sat, 3 Dec 2022 05:18:39 -0600 Subject: [PATCH 5/5] Saturate the vCpu on trial-olddeps too --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9a5c687edb22..f07655d982fb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -296,7 +296,7 @@ jobs: python-version: '3.7' extras: "all test" - - run: poetry run trial -j2 tests + - run: poetry run trial -j6 tests - name: Dump logs # Logs are most useful when the command fails, always include them. if: ${{ always() }}