Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exp/comp speedups #75

Open
wants to merge 66 commits into
base: unraid_develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
c777dd6
Change Complement startup to use unix socket
realtyem Dec 4, 2022
43164d6
Add in postgres tweaks file script
realtyem Dec 4, 2022
2ec40f7
Wire up the new performance script
realtyem Dec 4, 2022
a44614b
Fix up pathname
realtyem Dec 4, 2022
5172bfd
Move script to a better place
realtyem Dec 4, 2022
d6e913e
Fix dockerfile edits
realtyem Dec 4, 2022
75493bd
Put the script right in the dockerfile instead.
realtyem Dec 4, 2022
4740bcd
Try installing matrix onto a tmpfs while building. Should be copied l…
realtyem Dec 5, 2022
b0758a7
Switch back to localhost, and add passthrough option for host
realtyem Dec 5, 2022
d53ba23
Remove direct tmpfs hack that didn't work. Github doesn't expose bein…
realtyem Dec 5, 2022
c72e0da
Allow passing through START_POSTGRES and default to true in this cond…
realtyem Dec 5, 2022
4ccdb47
Try out a postgres docker for complement
realtyem Dec 6, 2022
d59d04e
Correct Postgres docker details
realtyem Dec 6, 2022
65d4f3d
Revert "Deal with go's get deprecation"
realtyem Dec 6, 2022
fda1b88
Update postgres host
realtyem Dec 6, 2022
867c961
Handle 'go get' deprecation (#14611)
realtyem Dec 5, 2022
1cca028
Try a tmpfs mounted /var/lib/docker
realtyem Dec 6, 2022
63f3462
add tmpfs to complement tests, and switch postgres host to internal d…
realtyem Dec 6, 2022
43a48fe
Remove the postgres docker bits, split complement in half
realtyem Dec 7, 2022
a572575
Fix tests-done
realtyem Dec 7, 2022
273a4cd
Disable docker on tmpfs
realtyem Dec 7, 2022
be85ddc
Disable docker build pre-warming
realtyem Dec 7, 2022
6d13fcc
Increase number of 'max_connections' to 500 for Complement and bump P…
realtyem Dec 7, 2022
c3a710a
Fix up rebase
realtyem Dec 23, 2022
acb180d
Put back Postgres 13
realtyem Dec 7, 2022
d8b94ad
Fix Postgres 13
realtyem Dec 8, 2022
d21d9dd
Try synchronous_commit=off for rei
realtyem Dec 10, 2022
33d8630
Bump number of concurrency to 4
realtyem Dec 10, 2022
ea9d738
try a bunch of stuff
realtyem Dec 13, 2022
cda556f
Eatmydata still wants to sync at the end before shutdown, placebo effect
realtyem Dec 17, 2022
7229cdb
Edit complement checkout to test new refactors.
realtyem Dec 30, 2022
cfeb4b3
Shoehorn postgresql-15 into complement docker image. And a few optimi…
realtyem Dec 30, 2022
a9cb9a0
Put the csapi/fed split on the back burner.
realtyem Dec 30, 2022
d482068
Missed a derp
realtyem Dec 30, 2022
6d47858
Bump parallel back up to 4. See what happens
realtyem Dec 30, 2022
f50a185
Add in a few checkpoint modifications to force Postgres to hurry up a…
realtyem Jan 1, 2023
36784af
Change complement branch we point to so we can test the changes.
realtyem Jan 1, 2023
da07a81
Remove all the Postgres performance improvements, hack newly discover…
realtyem Jan 1, 2023
9c2eb8d
Fix name of new synchronous_commit env variable to not be stupidly re…
realtyem Jan 2, 2023
59addb9
Update tests.yaml to show disk space usage of the runner.
realtyem Jan 3, 2023
e776138
Add another command to check memory free space as well.
realtyem Jan 3, 2023
2b449ec
Do it again after the tests, see what changes.
realtyem Jan 3, 2023
6a80b40
Implement swap space change for Github runner, set to 10Gb of swap.
realtyem Jan 3, 2023
084fd33
Test making background_updates faster.
realtyem Jan 3, 2023
f5083c3
Revert "Put the csapi/fed split on the back burner." Plus some fixups…
realtyem Jan 3, 2023
b2d1983
Why are derps so painful?
realtyem Jan 3, 2023
8cc0393
Re-enable Postgres tweaks since we need the more-than-100 connections…
realtyem Jan 3, 2023
5f54e62
Disable new ratelimiting that was introduced in 1.63. rc_invites.per_…
realtyem Jan 4, 2023
536f4dc
Further adjust for missing values. Also add the /_synapse/admin endpo…
realtyem Jan 5, 2023
7cd031f
Merge branch 'develop' into exp/comp-speedups
realtyem Jan 5, 2023
a102c22
Update some stuff
realtyem Jan 5, 2023
7c6ef11
Enable Complement debug logging.
realtyem Jan 7, 2023
54f2ffd
Disable complement logging, as it's not useful when it's destroying t…
realtyem Jan 9, 2023
85abf5c
Add nginx logging to the docker logs collected after a failed test run.
realtyem Jan 9, 2023
0f4774f
Reduce minimum retry timeout from 10 minutes(git add synapse/util/ret…
realtyem Jan 10, 2023
eb4aaa4
After much thought, leave parallel=2.
realtyem Jan 13, 2023
7069f7a
Crowbar asyncio and uvloop into the twisted reactor(I hope I did this…
realtyem Jan 15, 2023
5ddb8be
Lint found on crowbar. Next time use hammer.
realtyem Jan 15, 2023
70f8d81
And now crowbar them into worker mode.
realtyem Jan 15, 2023
86fa9eb
Try adjusting swappiness in tests to 90.
realtyem Jan 15, 2023
a3d3ea0
Exploratory tests 1
realtyem Jan 15, 2023
a11e604
Exploratory tests 2
realtyem Jan 15, 2023
ddf9e9d
Exploratory tests 3
realtyem Jan 15, 2023
b6112a3
Exploratory tests 4
realtyem Jan 15, 2023
1899c60
Try a swappiness value of 10, since it's on the opposite end of the s…
realtyem Jan 16, 2023
376237e
Try another fix to the docker builder yaml
realtyem Jan 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .ci/scripts/checkout_complement.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ mkdir -p complement
# 2. Attempt to use the base branch, e.g. when merging into release-vX.Y
# (GITHUB_BASE_REF for pull requests).
# 3. Use the default complement branch ("HEAD").
for BRANCH_NAME in "$GITHUB_HEAD_REF" "$GITHUB_BASE_REF" "${GITHUB_REF#refs/heads/}" "HEAD"; do
# for BRANCH_NAME in "$GITHUB_HEAD_REF" "$GITHUB_BASE_REF" "${GITHUB_REF#refs/heads/}" "HEAD"; do
# Skip empty branch names and merge commits.
if [[ -z "$BRANCH_NAME" || $BRANCH_NAME =~ ^refs/pull/.* ]]; then
continue
fi
# if [[ -z "$BRANCH_NAME" || $BRANCH_NAME =~ ^refs/pull/.* ]]; then
# continue
# fi

(wget -O - "https://github.com/matrix-org/complement/archive/$BRANCH_NAME.tar.gz" | tar -xz --strip-components=1 -C complement) && break
done
wget -O - "https://github.com/realtyem/complement/archive/refactor-ssapi-tests.tar.gz" | tar -xz --strip-components=1 -C complement
#done
18 changes: 0 additions & 18 deletions .flake8

This file was deleted.

3 changes: 1 addition & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ jobs:
latest=${{ github.ref == 'refs/heads/unraid_develop' }}
tags: |
type=raw,value=${{ github.ref_name }},enable=${{ github.ref != 'refs/heads/unraid_develop' }}
type=raw,value=unified,enable=${{ github.ref == 'refs/heads/unraid_develop' }}
type=semver,pattern={{version}}
type=pep440,pattern={{raw}}

- name: Build and push to repo

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/latest_deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: JasonEtco/create-an-issue@77399b6110ef82b94c1c9f9f615acf9e604f7f56 # v2.5.0, 2020-12-06
- uses: JasonEtco/create-an-issue@3a8ba796516b57db8cb2ee6dfc65bc76cd39d56d # v2.8.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
263 changes: 206 additions & 57 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- run: scripts-dev/check_schema_delta.py --force-colors

lint:
uses: "matrix-org/backend-meta/.github/workflows/python-poetry-ci.yml@v1"
uses: "matrix-org/backend-meta/.github/workflows/python-poetry-ci.yml@v2"
with:
typechecking-extras: "all"

Expand Down Expand Up @@ -161,33 +161,37 @@ jobs:

- run: cargo fmt --check

prewarm-cache:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: false
file: "docker/Dockerfile-unified"
tags: "realtyem/synapse:latest"
outputs: type=docker,dest=/tmp/synapse-prewarm.tar
cache-from: type=gha
# prewarm-cache:
# runs-on: ubuntu-22.04
# steps:
# - name: Checkout
# uses: actions/checkout@v3

# - name: Run Docker on tmpfs
# uses: JonasAlfredsson/docker-on-tmpfs@v1
# with:
# tmpfs_size: 5

# - name: Set up Docker Buildx
# id: buildx
# uses: docker/setup-buildx-action@v2

# - name: Build and push
# uses: docker/build-push-action@v3
# with:
# context: .
# push: false
# file: "docker/Dockerfile-unified"
# tags: "realtyem/synapse:latest"
# outputs: type=docker,dest=/tmp/synapse-prewarm.tar
# cache-from: type=gha
#cache-to: type=gha,mode=max

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: synapse-prewarm
path: /tmp/synapse-prewarm.tar

# - name: Upload artifact
# uses: actions/upload-artifact@v3
# with:
# name: synapse-prewarm
# path: /tmp/synapse-prewarm.tar

# Dummy step to gate other tests on without repeating the whole list
linting-done:
Expand All @@ -201,7 +205,7 @@ jobs:
- check-schema-delta
- lint-clippy
- lint-rustfmt
- prewarm-cache
# - prewarm-cache
runs-on: ubuntu-22.04
steps:
- run: "true"
Expand Down Expand Up @@ -528,7 +532,78 @@ jobs:
ported.sql
schema_diff

complement:
complement-csapi:
if: "${{ !failure() && !cancelled() }}"
needs: linting-done
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
- arrangement: monolith
database: SQLite

- arrangement: monolith
database: Postgres

- arrangement: workers
database: Postgres

steps:
- name: Increase Swap Memory space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 13

- name: Run actions/checkout@v3 for synapse
uses: actions/checkout@v3
with:
path: synapse

# - name: Run Docker on tmpfs
# uses: JonasAlfredsson/docker-on-tmpfs@v1
# with:
# tmpfs_size: 5

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Install Rust
# There don't seem to be versioned releases of this action per se: for each rust
# version there is a branch which gets constantly rebased on top of master.
# We pin to a specific commit for paranoia's sake.
uses: dtolnay/rust-toolchain@e645b0cf01249a964ec099494d38d2da0f0b349f
with:
toolchain: 1.58.1
- uses: Swatinem/rust-cache@v2

- name: Prepare Complement's Prerequisites
run: synapse/.ci/scripts/setup_complement_prerequisites.sh

- name: Check Disk and Memory Free Space
run: |
df -h
swapon --show
free -h

- run: |
set -o pipefail
ASYNCIO_REACTOR=1 POSTGRES=${{ (matrix.database == 'Postgres') && 1 || '' }} WORKERS=${{ (matrix.arrangement == 'workers') && 1 || '' }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement-csapi.sh -json 2>&1 | synapse/.ci/scripts/gotestfmt
shell: bash
env:
PASS_SYNAPSE_POSTGRES_ENABLE_SYNCHRONOUS_COMMIT: false
SYNAPSE_TEST_LOG_LEVEL: DEBUG
name: Run Complement Tests

- name: Check Disk and Memory Free Space
run: |
df -h
swapon --show
free -h

complement-fed:
if: "${{ !failure() && !cancelled() }}"
needs: linting-done
runs-on: ubuntu-latest
Expand All @@ -547,11 +622,21 @@ jobs:
database: Postgres

steps:
- name: Increase Swap Memory space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 13

- name: Run actions/checkout@v3 for synapse
uses: actions/checkout@v3
with:
path: synapse

# - name: Run Docker on tmpfs
# uses: JonasAlfredsson/docker-on-tmpfs@v1
# with:
# tmpfs_size: 5

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -568,44 +653,106 @@ jobs:
- name: Prepare Complement's Prerequisites
run: synapse/.ci/scripts/setup_complement_prerequisites.sh

- name: Download artifact
uses: actions/download-artifact@v3
- name: Check Disk and Memory Free Space
run: |
df -h
swapon --show
free -h

- run: |
set -o pipefail
ASYNCIO_REACTOR=1 POSTGRES=${{ (matrix.database == 'Postgres') && 1 || '' }} WORKERS=${{ (matrix.arrangement == 'workers') && 1 || '' }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement-fed.sh -json 2>&1 | synapse/.ci/scripts/gotestfmt
shell: bash
env:
SYNAPSE_TEST_LOG_LEVEL: DEBUG
PASS_SYNAPSE_POSTGRES_ENABLE_SYNCHRONOUS_COMMIT: false
name: Run Complement Tests

- name: Check Disk and Memory Free Space
run: |
df -h
swapon --show
free -h

complement:
if: "${{ !failure() && !cancelled() }}"
needs: linting-done
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
- arrangement: monolith
database: SQLite

- arrangement: monolith
database: Postgres

- arrangement: workers
database: Postgres

steps:
- name: Increase Swap Memory space
uses: pierotofy/set-swap-space@master
with:
name: synapse-prewarm
path: /tmp
swap-size-gb: 13

- name: Load image
- name: Adjust Memory Values
run: |
docker load --input /tmp/synapse-prewarm.tar
docker image ls -a

# - name: Build base
# uses: docker/build-push-action@v3
# with:
# context: .
# push: false
# file: "docker/Dockerfile-unified"
# tags: "synapse:latest"
# cache-from: type=gha
# cache-to: type=gha,mode=max

- name: Build Complement
uses: docker/build-push-action@v3
with:
context: ./synapse/docker/complement
push: false
load: true
file: "synapse/docker/complement/Dockerfile"
tags: "complement-synapse:latest"
# cache-from: type=gha
# cache-to: type=gha,mode=max
sudo cat /proc/sys/vm/swappiness
sudo sysctl vm.swappiness=10
sudo cat /proc/sys/vm/swappiness
echo 0 | sudo tee /sys/class/block/sda/queue/rotational
echo 1024 | sudo tee /sys/class/block/sda/queue/read_ahead_kb

- name: Run actions/checkout@v3 for synapse
uses: actions/checkout@v3
with:
path: synapse

# - name: Run Docker on tmpfs
# uses: JonasAlfredsson/docker-on-tmpfs@v1
# with:
# tmpfs_size: 5

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Install Rust
# There don't seem to be versioned releases of this action per se: for each rust
# version there is a branch which gets constantly rebased on top of master.
# We pin to a specific commit for paranoia's sake.
uses: dtolnay/rust-toolchain@e645b0cf01249a964ec099494d38d2da0f0b349f
with:
toolchain: 1.58.1
- uses: Swatinem/rust-cache@v2

- name: Prepare Complement's Prerequisites
run: synapse/.ci/scripts/setup_complement_prerequisites.sh

- name: Check Disk and Memory Free Space
run: |
df -h
swapon --show
free -h

- run: |
set -o pipefail
POSTGRES=${{ (matrix.database == 'Postgres') && 1 || '' }} WORKERS=${{ (matrix.arrangement == 'workers') && 1 || '' }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -f -json 2>&1 | synapse/.ci/scripts/gotestfmt
ASYNCIO_REACTOR=1 POSTGRES=${{ (matrix.database == 'Postgres') && 1 || '' }} WORKERS=${{ (matrix.arrangement == 'workers') && 1 || '' }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | synapse/.ci/scripts/gotestfmt
shell: bash
env:
SYNAPSE_TEST_LOG_LEVEL: DEBUG
PASS_SYNAPSE_POSTGRES_ENABLE_SYNCHRONOUS_COMMIT: false
name: Run Complement Tests

- name: Check Disk and Memory Free Space
run: |
df -h
swapon --show
free -h

cargo-test:
if: ${{ needs.changes.outputs.rust == 'true' }}
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -636,6 +783,8 @@ jobs:
- sytest
- export-data
- portdb
- complement-fed
- complement-csapi
- complement
- cargo-test
runs-on: ubuntu-22.04
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/twisted_trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: JasonEtco/create-an-issue@77399b6110ef82b94c1c9f9f615acf9e604f7f56 # v2.5.0, 2020-12-06
- uses: JasonEtco/create-an-issue@3a8ba796516b57db8cb2ee6dfc65bc76cd39d56d # v2.8.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
Loading