Benchmark pg_analytics #318
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# workflows/benchmark-pg_analytics.yml | |
# | |
# Benchmark pg_analytics | |
# Benchmark ParadeDB's pg_analytics performance against ClickBench. | |
name: Benchmark pg_analytics | |
on: | |
schedule: | |
- cron: "1 0 * * 1,2,3,4,5" # Run once per day on weekdays (days of the week 1-5) at 00:01 UTC | |
pull_request: | |
types: [opened, synchronize, reopened, ready_for_review] | |
branches: | |
- dev | |
- main | |
paths: | |
- ".github/workflows/benchmark-pg_analytics.yml" | |
- "src/**" | |
- "Cargo.toml" | |
- "pg_analytics.control" | |
push: | |
branches: | |
- dev # Also run on dev to fill the GitHub Actions Rust cache in a way that pull requests can see it | |
paths: | |
- "**/*.rs" | |
- "**/*.toml" | |
workflow_dispatch: | |
concurrency: | |
group: benchmark-pg_analytics-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
benchmark-pg_analytics: | |
name: Benchmark pg_analytics on ${{ matrix.name }} | |
runs-on: ubicloud-standard-8 | |
if: github.event.pull_request.draft == false | |
strategy: | |
matrix: | |
include: | |
- name: ClickBench (Parquet, single) | |
flags: -w single | |
pg_version: 17 | |
- name: ClickBench (Parquet, partitioned) | |
flags: -w partitioned | |
pg_version: 17 | |
steps: | |
- name: Checkout Git Repository | |
uses: actions/checkout@v4 | |
# To access the cargo-paradedb benchmarking tool | |
- name: Checkout paradedb/paradedb Git Repository | |
run: git clone https://github.com/paradedb/paradedb | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install & Configure Supported PostgreSQL Version | |
run: | | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' | |
sudo apt-get update && sudo apt-get install -y postgresql-${{ matrix.pg_version }} postgresql-server-dev-${{ matrix.pg_version }} | |
sudo chown -R $(whoami) /usr/share/postgresql/${{ matrix.pg_version }}/ /usr/lib/postgresql/${{ matrix.pg_version }}/ /var/lib/postgresql/${{ matrix.pg_version }}/ | |
echo "/usr/lib/postgresql/${{ matrix.pg_version }}/bin" >> $GITHUB_PATH | |
- name: Extract pgrx Version | |
id: pgrx | |
run: echo version=$(cargo tree --depth 1 -i pgrx -p pg_analytics | head -n 1 | cut -f2 -dv) >> $GITHUB_OUTPUT | |
- name: Install Rust Cache | |
uses: ubicloud/rust-cache@v2 | |
with: | |
prefix-key: "v1-rust" | |
key: ${{ matrix.pg_version }}-${{ steps.pgrx.outputs.version }} | |
cache-targets: true | |
cache-all-crates: true | |
save-if: ${{ github.ref == 'refs/heads/dev' }} | |
- name: Install pgrx & pg_analytics | |
run: | | |
cargo install -j $(nproc) --locked cargo-pgrx --version ${{ steps.pgrx.outputs.version }} | |
cargo pgrx init --pg${{ matrix.pg_version }}=/usr/lib/postgresql/${{ matrix.pg_version }}/bin/pg_config | |
cargo pgrx install --pg-config="/usr/lib/postgresql/${{ matrix.pg_version }}/bin/pg_config" --release | |
- name: Add pg_analytics to shared_preload_libraries | |
working-directory: /home/runner/.pgrx/data-${{ matrix.pg_version }}/ | |
run: sed -i "s/^#shared_preload_libraries = .*/shared_preload_libraries = 'pg_analytics'/" postgresql.conf | |
- name: Install the ParadeDB Benchmarking Tool | |
working-directory: paradedb/cargo-paradedb/ | |
run: cargo run install | |
- name: Run Official ${{ matrix.name }} Benchmark | |
run: | | |
cargo pgrx start pg${{ matrix.pg_version }} | |
cargo paradedb bench hits run ${{ matrix.flags }} --url postgresql://localhost:288${{ matrix.pg_version }}/postgres | |
- name: Notify Slack on Failure | |
if: failure() && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main') | |
run: | | |
curl -X POST -H 'Content-type: application/json' --data '{"text":"Benchmark pg_analytics on ${{ matrix.name }} workflow failed in `paradedb/paradedb` -- investigate immediately!"}' ${{ secrets.SLACK_WEBHOOK_URL }} |