-
Notifications
You must be signed in to change notification settings - Fork 60
146 lines (125 loc) · 5.16 KB
/
parser-delegation-perf.yml
File metadata and controls
146 lines (125 loc) · 5.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Parser Delegation Perf
# Measures the wall-time cost of routing the public parser API through a
# composed `WP_MySQL_Native_Parser` instance (this PR) instead of letting
# `WP_MySQL_Parser` directly extend the Rust class (PR base). The parse
# benchmark walks the full MySQL server-suite corpus on both branches —
# the delta is the per-call delegation cost.
on:
push:
paths:
- '.github/workflows/parser-delegation-perf.yml'
- 'packages/mysql-on-sqlite/src/mysql/native/**'
- 'packages/mysql-on-sqlite/tests/tools/run-parser-benchmark.php'
- 'packages/php-ext-wp-mysql-parser/**'
pull_request:
paths:
- '.github/workflows/parser-delegation-perf.yml'
- 'packages/mysql-on-sqlite/src/mysql/native/**'
- 'packages/mysql-on-sqlite/tests/tools/run-parser-benchmark.php'
- 'packages/php-ext-wp-mysql-parser/**'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
perf:
name: Parser delegation benchmark
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
coverage: none
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install native build dependencies
run: |
sudo apt-get update
sudo apt-get install -y libclang-dev
echo "PHP_CONFIG=$(command -v php-config)" >> "$GITHUB_ENV"
LIBCLANG_SO="$(find /usr/lib -name 'libclang.so*' | head -n 1)"
echo "LIBCLANG_PATH=$(dirname "$LIBCLANG_SO")" >> "$GITHUB_ENV"
- name: Install Composer dependencies (root)
uses: ramsey/composer-install@v3
with:
ignore-cache: "yes"
composer-options: "--optimize-autoloader"
- name: Install Composer dependencies (mysql-on-sqlite)
uses: ramsey/composer-install@v3
with:
working-directory: packages/mysql-on-sqlite
ignore-cache: "yes"
composer-options: "--optimize-autoloader"
- name: Download MySQL test query corpus
working-directory: packages/mysql-on-sqlite
run: bash tests/tools/mysql-download-tests.sh || true
- name: Build parser extension (release)
run: cargo build --release
working-directory: packages/php-ext-wp-mysql-parser
- name: Locate built extension
run: |
EXT="$GITHUB_WORKSPACE/packages/php-ext-wp-mysql-parser/target/release/libwp_mysql_parser.so"
test -f "$EXT" || { echo "Extension not built at $EXT"; exit 1; }
echo "NATIVE_EXT=$EXT" >> "$GITHUB_ENV"
- name: Benchmark — this PR (trait delegation)
working-directory: packages/mysql-on-sqlite
run: |
for i in 1 2 3; do
echo "=== run $i ==="
php -d extension="$NATIVE_EXT" tests/tools/run-parser-benchmark.php
done | tee "$GITHUB_WORKSPACE/this-pr.txt"
- name: Check out baseline (PR base, direct extends)
run: |
git fetch --no-tags --depth=1 origin codex/native-lazy-ast-facade
git worktree add ../baseline FETCH_HEAD
- name: Install Composer dependencies (baseline)
uses: ramsey/composer-install@v3
with:
working-directory: ../baseline/packages/mysql-on-sqlite
ignore-cache: "yes"
composer-options: "--optimize-autoloader"
- name: Build baseline parser extension (release)
run: cargo build --release
working-directory: ../baseline/packages/php-ext-wp-mysql-parser
- name: Stage corpus into baseline
run: |
mkdir -p ../baseline/packages/mysql-on-sqlite/tests/mysql/data
cp packages/mysql-on-sqlite/tests/mysql/data/*.csv \
../baseline/packages/mysql-on-sqlite/tests/mysql/data/ 2>/dev/null || true
- name: Benchmark — baseline (direct extends)
working-directory: ../baseline/packages/mysql-on-sqlite
run: |
BASE_EXT="$(realpath ../../packages/php-ext-wp-mysql-parser/target/release/libwp_mysql_parser.so)"
for i in 1 2 3; do
echo "=== run $i ==="
php -d extension="$BASE_EXT" tests/tools/run-parser-benchmark.php
done | tee "$GITHUB_WORKSPACE/baseline.txt"
- name: Summarize
if: always()
run: |
{
echo '### Parser delegation perf'
echo
echo '#### This PR (`use WP_MySQL_Native_Parser_Impl;`)'
echo '```'
cat "$GITHUB_WORKSPACE/this-pr.txt" 2>/dev/null || echo 'no output'
echo '```'
echo
echo '#### Baseline (`extends WP_MySQL_Native_Parser`)'
echo '```'
cat "$GITHUB_WORKSPACE/baseline.txt" 2>/dev/null || echo 'no output'
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload raw output
if: always()
uses: actions/upload-artifact@v4
with:
name: parser-delegation-perf-${{ github.run_id }}
path: |
this-pr.txt
baseline.txt
if-no-files-found: warn