|
| 1 | +name: Rust micro-benchmarks |
| 2 | + |
| 3 | +# Reusable workflow for the Rust micro-benchmarks (random access, compression). Called by bench.yml |
| 4 | +# (mode=develop) and bench-pr.yml (mode=pr). The matrix is resolved declaratively from |
| 5 | +# bench-orchestrator; see bench-orchestrator/bench_orchestrator/matrix.py. |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_call: |
| 9 | + inputs: |
| 10 | + mode: |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + profile: |
| 14 | + required: false |
| 15 | + type: string |
| 16 | + default: "micro" |
| 17 | + |
| 18 | +jobs: |
| 19 | + plan: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + timeout-minutes: 10 |
| 22 | + outputs: |
| 23 | + matrix: ${{ steps.resolve.outputs.matrix }} |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 |
| 26 | + if: inputs.mode == 'pr' |
| 27 | + with: |
| 28 | + ref: ${{ github.event.pull_request.head.sha }} |
| 29 | + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 |
| 30 | + if: inputs.mode != 'pr' |
| 31 | + - name: Install uv |
| 32 | + uses: spiraldb/actions/.github/actions/setup-uv@a746510eafaa926484c354541cfc49b2ec06cc63 # 0.18.6 |
| 33 | + with: |
| 34 | + sync: false |
| 35 | + - name: Resolve benchmark matrix |
| 36 | + id: resolve |
| 37 | + shell: bash |
| 38 | + env: |
| 39 | + PROFILE: ${{ inputs.profile }} |
| 40 | + run: | |
| 41 | + echo "matrix=$(uv run --project bench-orchestrator vx-bench matrix "$PROFILE")" >> "$GITHUB_OUTPUT" |
| 42 | +
|
| 43 | + bench: |
| 44 | + needs: plan |
| 45 | + timeout-minutes: 120 |
| 46 | + env: |
| 47 | + RUST_BACKTRACE: full |
| 48 | + VORTEX_EXPERIMENTAL_PATCHED_ARRAY: "1" |
| 49 | + FLAT_LAYOUT_INLINE_ARRAY_NODE: "1" |
| 50 | + strategy: |
| 51 | + fail-fast: false |
| 52 | + matrix: |
| 53 | + include: ${{ fromJSON(needs.plan.outputs.matrix) }} |
| 54 | + |
| 55 | + runs-on: >- |
| 56 | + ${{ github.repository == 'vortex-data/vortex' |
| 57 | + && format('runs-on={0}/runner=bench-dedicated/tag={1}{2}', github.run_id, matrix.id, (inputs.mode != 'pr' || github.event.pull_request.head.repo.fork == false) && '/extras=s3-cache' || '') |
| 58 | + || 'ubuntu-latest' }} |
| 59 | + steps: |
| 60 | + - uses: runs-on/action@v2 |
| 61 | + if: inputs.mode != 'pr' || github.event.pull_request.head.repo.fork == false |
| 62 | + with: |
| 63 | + sccache: s3 |
| 64 | + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 |
| 65 | + if: inputs.mode == 'pr' |
| 66 | + with: |
| 67 | + ref: ${{ github.event.pull_request.head.sha }} |
| 68 | + |
| 69 | + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 |
| 70 | + if: inputs.mode != 'pr' |
| 71 | + - name: Setup benchmark environment |
| 72 | + run: sudo bash scripts/setup-benchmark.sh |
| 73 | + - uses: ./.github/actions/setup-rust |
| 74 | + with: |
| 75 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + enable-sccache: ${{ (inputs.mode != 'pr' || github.event.pull_request.head.repo.fork == false) && 'true' || 'false' }} |
| 77 | + - name: Install uv |
| 78 | + uses: spiraldb/actions/.github/actions/setup-uv@a746510eafaa926484c354541cfc49b2ec06cc63 # 0.18.6 |
| 79 | + with: |
| 80 | + sync: false |
| 81 | + |
| 82 | + - name: Install DuckDB |
| 83 | + run: | |
| 84 | + wget -qO- https://github.com/duckdb/duckdb/releases/download/v1.5.4/duckdb_cli-linux-amd64.zip | funzip > duckdb |
| 85 | + chmod +x duckdb |
| 86 | + echo "$PWD" >> "$GITHUB_PATH" |
| 87 | +
|
| 88 | + - uses: ./.github/actions/system-info |
| 89 | + |
| 90 | + - name: Build binary |
| 91 | + shell: bash |
| 92 | + env: |
| 93 | + RUSTFLAGS: "-C target-cpu=native" |
| 94 | + run: | |
| 95 | + cargo build --bin ${{ matrix.id }} --profile release_debug ${{ matrix.build_args }} --features unstable_encodings |
| 96 | +
|
| 97 | + - name: Setup Polar Signals |
| 98 | + if: inputs.mode != 'pr' || github.event.pull_request.head.repo.fork == false |
| 99 | + uses: polarsignals/gh-actions-ps-profiling@68ae857e375a826606352016e5b90f01a2a7ff7a # v0.8.1 |
| 100 | + with: |
| 101 | + polarsignals_cloud_token: ${{ secrets.POLAR_SIGNALS_API_KEY }} |
| 102 | + labels: "branch=${{ github.ref_name }};gh_run_id=${{ github.run_id }};benchmark=${{ matrix.id }}" |
| 103 | + project_uuid: "e5d846e1-b54c-46e7-9174-8bf055a3af56" |
| 104 | + profiling_frequency: 199 |
| 105 | + extra_args: "--off-cpu-threshold=0.03" # Personally tuned by @brancz |
| 106 | + |
| 107 | + - name: Run ${{ matrix.name }} benchmark (per-combination) |
| 108 | + if: ${{ matrix.split }} |
| 109 | + shell: bash |
| 110 | + run: | |
| 111 | + python3 scripts/random-access-split.py ${{ inputs.mode != 'pr' && '--v3' || '' }} |
| 112 | +
|
| 113 | + - name: Run ${{ matrix.name }} benchmark |
| 114 | + if: ${{ !matrix.split }} |
| 115 | + shell: bash |
| 116 | + run: | |
| 117 | + bash scripts/bench-taskset.sh target/release_debug/${{ matrix.id }} \ |
| 118 | + --formats ${{ matrix.formats }} \ |
| 119 | + -d gh-json \ |
| 120 | + -o results.json \ |
| 121 | + ${{ inputs.mode != 'pr' && '--gh-json-v3 results.v3.jsonl' || '' }} |
| 122 | +
|
| 123 | + - name: Setup AWS CLI |
| 124 | + if: inputs.mode != 'pr' || github.event.pull_request.head.repo.fork == false |
| 125 | + uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6 |
| 126 | + with: |
| 127 | + role-to-assume: arn:aws:iam::245040174862:role/GitHubBenchmarkRole |
| 128 | + aws-region: us-east-1 |
| 129 | + |
| 130 | + - name: Compare results |
| 131 | + if: inputs.mode == 'pr' |
| 132 | + shell: bash |
| 133 | + run: | |
| 134 | + set -Eeu -o pipefail -x |
| 135 | +
|
| 136 | + python3 scripts/s3-download.py s3://vortex-ci-benchmark-results/data.json.gz data.json.gz --no-sign-request |
| 137 | + gzip -d -c data.json.gz > base.json |
| 138 | +
|
| 139 | + echo "# Benchmarks: ${{ matrix.name }}" > comment.md |
| 140 | + echo '' >> comment.md |
| 141 | + uv run --no-project scripts/compare-benchmark-jsons.py base.json results.json "${{ matrix.name }}" \ |
| 142 | + >> comment.md |
| 143 | + cat comment.md >> "$GITHUB_STEP_SUMMARY" |
| 144 | +
|
| 145 | + - name: Comment PR |
| 146 | + if: inputs.mode == 'pr' && github.event.pull_request.head.repo.fork == false |
| 147 | + uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3 |
| 148 | + with: |
| 149 | + file-path: comment.md |
| 150 | + comment-tag: bench-pr-comment-${{ matrix.id }} |
| 151 | + |
| 152 | + - name: Comment PR on failure |
| 153 | + if: failure() && inputs.mode == 'pr' && github.event.pull_request.head.repo.fork == false |
| 154 | + uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3 |
| 155 | + with: |
| 156 | + message: | |
| 157 | + # BENCHMARK FAILED |
| 158 | +
|
| 159 | + Benchmark `${{ matrix.name }}` failed! Check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details. |
| 160 | + comment-tag: bench-pr-comment-${{ matrix.id }} |
| 161 | + |
| 162 | + - name: Upload Benchmark Results |
| 163 | + if: inputs.mode == 'develop' |
| 164 | + shell: bash |
| 165 | + run: | |
| 166 | + bash scripts/cat-s3.sh vortex-ci-benchmark-results data.json.gz results.json |
| 167 | +
|
| 168 | + # v4 (Postgres) ingest -- the REQUIRED benchmark-results pipeline feeding the live benchmarks |
| 169 | + # website (see bench.yml for the full rationale). Gated on inputs.mode == 'develop' + the |
| 170 | + # ingest-role ARN var. post-ingest.py mints the RDS IAM token (boto3) from the assumed |
| 171 | + # GitHubBenchmarkIngestRole; sslmode=verify-full validates the cert. |
| 172 | + - name: Configure AWS credentials for v4 ingest (OIDC) |
| 173 | + if: inputs.mode == 'develop' && vars.GH_BENCH_INGEST_ROLE_ARN != '' |
| 174 | + uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b # v6 |
| 175 | + with: |
| 176 | + role-to-assume: ${{ vars.GH_BENCH_INGEST_ROLE_ARN }} |
| 177 | + aws-region: ${{ vars.RDS_BENCH_REGION }} |
| 178 | + - name: Ingest results to v4 Postgres |
| 179 | + if: inputs.mode == 'develop' && vars.GH_BENCH_INGEST_ROLE_ARN != '' |
| 180 | + shell: bash |
| 181 | + env: |
| 182 | + RDS_BENCH_INSTANCE_ENDPOINT: ${{ vars.RDS_BENCH_INSTANCE_ENDPOINT }} |
| 183 | + RDS_BENCH_DB_NAME: ${{ vars.RDS_BENCH_DB_NAME }} |
| 184 | + AWS_REGION: ${{ vars.RDS_BENCH_REGION }} |
| 185 | + BENCH_SITE_BASE_URL: ${{ vars.BENCH_SITE_BASE_URL }} |
| 186 | + BENCH_REVALIDATE_TOKEN: ${{ secrets.BENCH_REVALIDATE_TOKEN }} |
| 187 | + run: | |
| 188 | + set -Eeuo pipefail |
| 189 | + curl -fsSL https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem \ |
| 190 | + -o "${RUNNER_TEMP}/rds-global-bundle.pem" |
| 191 | + DSN="postgresql://bench_ingest@${RDS_BENCH_INSTANCE_ENDPOINT}:5432/${RDS_BENCH_DB_NAME}?sslmode=verify-full&sslrootcert=${RUNNER_TEMP}/rds-global-bundle.pem" |
| 192 | + uv run --no-project --with 'psycopg[binary]' --with boto3 --with xxhash \ |
| 193 | + scripts/post-ingest.py results.v3.jsonl \ |
| 194 | + --postgres "${DSN}" \ |
| 195 | + --commit-sha "${{ github.sha }}" \ |
| 196 | + --region "${AWS_REGION}" |
| 197 | +
|
| 198 | + - name: Alert incident.io |
| 199 | + if: failure() && inputs.mode == 'develop' |
| 200 | + uses: ./.github/actions/alert-incident-io |
| 201 | + with: |
| 202 | + api-key: ${{ secrets.INCIDENT_IO_ALERT_TOKEN }} |
| 203 | + alert-title: "${{ matrix.name }} benchmark failed on develop" |
| 204 | + deduplication-key: ci-bench-${{ matrix.id }}-failure |
0 commit comments