@@ -2,13 +2,69 @@ name: Real-time Benchmark
22on :
33 schedule :
44 - cron : " 30 0 * * *"
5+ workflow_dispatch :
6+ inputs :
7+ repository :
8+ description : ' Repository name that is going to be benchmarked (e.g. "johndoe/php-src")'
9+ required : true
10+ type : string
11+ branch :
12+ description : ' Branch name that is going to be benchmarked (e.g. "my-branch")'
13+ required : true
14+ type : string
15+ commit :
16+ description : ' Full commit SHA that is going to be benchmarked (e.g. "123456789a...")'
17+ required : true
18+ type : string
19+ baseline_commit :
20+ description : ' Full commit SHA that is compared against the one provided by the "commit" input (e.g. "abcdef123456...")'
21+ required : true
22+ type : string
23+ id :
24+ description : ' ID of the benchmarked code. It should be a valid identifier (e.g. "master", "php_85").'
25+ required : true
26+ type : string
27+ opcache :
28+ description : ' Whether opcache should be enabled'
29+ required : true
30+ default : " 1"
31+ type : choice
32+ options :
33+ - " 0"
34+ - " 1"
35+ - " 2"
36+ baseline_opcache :
37+ description : ' Whether opcache should be enabled'
38+ required : true
39+ default : " 1"
40+ type : choice
41+ options :
42+ - " 0"
43+ - " 1"
44+ - " 2"
45+ jit :
46+ description : ' Whether JIT is benchmarked'
47+ required : false
48+ type : choice
49+ options :
50+ - " 0"
51+ - " 1"
552permissions :
653 contents : read
754jobs :
855 REAL_TIME_BENCHMARK :
956 name : REAL_TIME_BENCHMARK
10- if : github.repository == 'php /php-src'
57+ if : github.repository == 'kocsismate /php-src' || github.event_name == 'workflow_dispatch '
1158 runs-on : ubuntu-22.04
59+ env :
60+ REPOSITORY : ${{ inputs.repository || 'php/php-src' }}
61+ BRANCH : ${{ inputs.branch || 'master' }}
62+ COMMIT : ${{ inputs.commit || github.sha }}
63+ BASELINE_COMMIT : ${{ inputs.baseline_commit || 'd5f6e56610c729710073350af318c4ea1b292cfe' }}
64+ ID : ${{ inputs.id || 'master' }}
65+ OPCACHE : ${{ inputs.opcache || '1' }}
66+ BASELINE_OPCACHE : ${{ inputs.baseline_opcache || '2' }}
67+ JIT : ${{ inputs.jit || '1' }}
1268 steps :
1369 - name : Install dependencies
1470 run : |
@@ -29,73 +85,144 @@ jobs:
2985 ref : ' main'
3086 fetch-depth : 1
3187 path : ' php-version-benchmarks'
32- - name : Checkout php-src
88+ - name : Checkout php-src (benchmarked version)
3389 uses : actions/checkout@v4
3490 with :
35- repository : ' php/php-src '
36- ref : ' ${{ github.sha }}'
91+ repository : ' ${{ env.REPOSITORY }} '
92+ ref : ' ${{ env.COMMIT }}'
3793 fetch-depth : 100
38- path : ' php-version-benchmarks/tmp/php_master'
94+ path : ' php-version-benchmarks/tmp/php_${{ env.ID }}'
95+ - name : Checkout php-src (baseline version)
96+ uses : actions/checkout@v4
97+ with :
98+ repository : ' ${{ env.REPOSITORY }}'
99+ ref : ' ${{ env.BASELINE_COMMIT }}'
100+ fetch-depth : 100
101+ path : ' php-version-benchmarks/tmp/php_baseline'
39102 - name : Setup benchmark results
40103 run : |
41104 git config --global user.name "Benchmark"
42105 git config --global user.email "[email protected] " 43-
106+
44107 rm -rf ./php-version-benchmarks/docs/results
45108 - name : Checkout benchmark data
109+ if : github.repository == 'kocsismate/php-src' && github.event_name != 'workflow_dispatch'
46110 uses : actions/checkout@v4
47111 with :
48112 repository : php/real-time-benchmark-data
49113 ssh-key : ${{ secrets.PHP_VERSION_BENCHMARK_RESULTS_DEPLOY_KEY }}
50114 path : ' php-version-benchmarks/docs/results'
51- - name : Set benchmark config
115+ - name : Setup infra config
52116 run : |
53117 set -e
54118
55- # Set infrastructure config
56119 cp ./php-version-benchmarks/config/infra/aws/x86_64-metal.ini.dist ./php-version-benchmarks/config/infra/aws/x86_64-metal.ini
57120 ESCAPED_DOCKER_REGISTRY=$(printf '%s\n' "${{ secrets.PHP_VERSION_BENCHMARK_DOCKER_REGISTRY }}" | sed -e 's/[\/&]/\\&/g')
58121 sed -i "s/INFRA_DOCKER_REGISTRY=public.ecr.aws\/abcdefgh/INFRA_DOCKER_REGISTRY=$ESCAPED_DOCKER_REGISTRY/g" ./php-version-benchmarks/config/infra/aws/x86_64-metal.ini
59122 cp ./php-version-benchmarks/build/infrastructure/config/aws.tfvars.dist ./php-version-benchmarks/build/infrastructure/config/aws.tfvars
60123 sed -i 's/access_key = ""/access_key = "${{ secrets.PHP_VERSION_BENCHMARK_AWS_ACCESS_KEY }}"/g' ./php-version-benchmarks/build/infrastructure/config/aws.tfvars
61124 sed -i 's/secret_key = ""/secret_key = "${{ secrets.PHP_VERSION_BENCHMARK_AWS_SECRET_KEY }}"/g' ./php-version-benchmarks/build/infrastructure/config/aws.tfvars
125+ sed -i 's/github_token = ""/github_token = "${{ secrets.PHP_VERSION_BENCHMARK_GITHUB_TOKEN }}"/g' ./php-version-benchmarks/build/infrastructure/config/aws.tfvars
126+ - name : Setup PHP config - baseline PHP version
127+ if : github.repository == 'kocsismate/php-src' && github.event_name != 'workflow_dispatch'
128+ run : |
129+ set -e
130+
131+ BASELINE_SHORT_SHA="$(echo "${{ env.BASELINE_COMMIT }}" | cut -c1-4)"
132+
133+ cat << EOF > ./php-version-benchmarks/config/php/baseline.ini
134+ PHP_NAME="PHP - baseline@$BASELINE_SHORT_SHA"
135+ PHP_ID=php_baseline
136+
137+ PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git
138+ PHP_BRANCH=${{ env.BRANCH }}
139+ PHP_COMMIT=${{ env.BASELINE_COMMIT }}
140+
141+ PHP_OPCACHE=${{ env.BASELINE_OPCACHE }}
142+ PHP_JIT=0
143+ EOF
144+ - name : Setup PHP config - baseline PHP version with JIT (manual only)
145+ if : github.repository == 'kocsismate/php-src' && github.event_name == 'workflow_dispatch' && inputs.jit == '1'
146+ run : |
147+ set -e
148+
149+ BASELINE_SHORT_SHA="$(echo "${{ env.BASELINE_COMMIT }}" | cut -c1-4)"
150+
151+ cat << EOF > ./php-version-benchmarks/config/php/baseline.ini
152+ PHP_NAME="PHP - baseline@$BASELINE_SHORT_SHA (JIT)"
153+ PHP_ID=php_baseline_jit
154+
155+ PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git
156+ PHP_BRANCH=${{ env.BRANCH }}
157+ PHP_COMMIT=${{ env.BASELINE_COMMIT }}
158+
159+ PHP_OPCACHE=${{ env.BASELINE_OPCACHE }}
160+ PHP_JIT=${{ env.JIT }}
161+ EOF
162+
163+ git clone ./php-version-benchmarks/tmp/php_baseline/ ./php-version-benchmarks/tmp/php_baseline_jit
164+ - name : Setup PHP config - previous PHP version (scheduled only)
165+ if : github.repository == 'kocsismate/php-src' && github.event_name != 'workflow_dispatch'
166+ run : |
167+ set -e
62168
63169 YEAR="$(date '+%Y')"
64170 DATABASE="./php-version-benchmarks/docs/results/$YEAR/database.tsv"
65171 if [ -f "$DATABASE" ]; then
66172 LAST_RESULT_SHA="$(tail -n 2 "$DATABASE" | head -n 1 | cut -f 6)"
67173 else
68174 YESTERDAY="$(date -d "-2 day 23:59:59" '+%Y-%m-%d %H:%M:%S')"
69- LAST_RESULT_SHA="$(cd ./php-version-benchmarks/tmp/php_master / && git --no-pager log --until="$YESTERDAY" -n 1 --pretty='%H')"
175+ LAST_RESULT_SHA="$(cd ./php-version-benchmarks/tmp/php_${{ env.ID }} / && git --no-pager log --until="$YESTERDAY" -n 1 --pretty='%H')"
70176 fi
71177
72- BASELINE_SHA="d5f6e56610c729710073350af318c4ea1b292cfe"
73- BASELINE_SHORT_SHA="$(echo "$BASELINE_SHA" | cut -c1-4)"
74-
75- # Set config for the baseline PHP version
76- cp ./php-version-benchmarks/config/php/master.ini.dist ./php-version-benchmarks/config/php/master_baseline.ini
77- sed -i 's/PHP_NAME="PHP - master"/PHP_NAME="PHP - baseline@'"$BASELINE_SHORT_SHA"'"/g' ./php-version-benchmarks/config/php/master_baseline.ini
78- sed -i "s/PHP_ID=php_master/PHP_ID=php_master_baseline/g" ./php-version-benchmarks/config/php/master_baseline.ini
79- sed -i "s/PHP_COMMIT=/PHP_COMMIT=$BASELINE_SHA/g" ./php-version-benchmarks/config/php/master_baseline.ini
80- sed -i "s/PHP_OPCACHE=1/PHP_OPCACHE=2/g" ./php-version-benchmarks/config/php/master_baseline.ini
81-
82- # Set config for the previous PHP version
83- cp ./php-version-benchmarks/config/php/master.ini.dist ./php-version-benchmarks/config/php/master_last.ini
84- sed -i 's/PHP_NAME="PHP - master"/PHP_NAME="PHP - previous master"/g' ./php-version-benchmarks/config/php/master_last.ini
85- sed -i "s/PHP_ID=php_master/PHP_ID=php_master_previous/g" ./php-version-benchmarks/config/php/master_last.ini
86- sed -i "s/PHP_COMMIT=/PHP_COMMIT=$LAST_RESULT_SHA/g" ./php-version-benchmarks/config/php/master_last.ini
87- sed -i "s/PHP_OPCACHE=1/PHP_OPCACHE=2/g" ./php-version-benchmarks/config/php/master_last.ini
88-
89- # Set config for the current PHP version
90- cp ./php-version-benchmarks/config/php/master.ini.dist ./php-version-benchmarks/config/php/master_now.ini
91- sed -i "s/PHP_COMMIT=/PHP_COMMIT=${{ github.sha }}/g" ./php-version-benchmarks/config/php/master_now.ini
92-
93- # Set config for current PHP version with JIT
94- git clone ./php-version-benchmarks/tmp/php_master/ ./php-version-benchmarks/tmp/php_master_jit
95- cp ./php-version-benchmarks/config/php/master_jit.ini.dist ./php-version-benchmarks/config/php/master_now_jit.ini
96- sed -i "s/PHP_COMMIT=/PHP_COMMIT=${{ github.sha }}/g" ./php-version-benchmarks/config/php/master_now_jit.ini
97-
98- # Set test configs
178+ cat << EOF > ./php-version-benchmarks/config/php/previous.ini
179+ PHP_NAME="PHP - previous ${{ env.BRANCH }}"
180+ PHP_ID=php_previous
181+
182+ PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git
183+ PHP_BRANCH=${{ env.BRANCH }}
184+ PHP_COMMIT=$LAST_RESULT_SHA
185+
186+ PHP_OPCACHE=1
187+ PHP_JIT=0
188+ EOF
189+ - name : Setup PHP config - benchmarked PHP version
190+ run : |
191+ set -e
192+
193+ cat << EOF > ./php-version-benchmarks/config/php/this.ini
194+ PHP_NAME="PHP - ${{ env.BRANCH }}"
195+ PHP_ID=php_${{ env.ID }}
196+
197+ PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git
198+ PHP_BRANCH=${{ env.BRANCH }}
199+ PHP_COMMIT=${{ env.COMMIT }}
200+
201+ PHP_OPCACHE=${{ env.OPCACHE }}
202+ PHP_JIT=0
203+ EOF
204+ - name : Setup PHP config - benchmarked PHP version with JIT
205+ if : env.JIT == '1'
206+ run : |
207+ set -e
208+
209+ cat << EOF > ./php-version-benchmarks/config/php/this_jit.ini
210+ PHP_NAME="PHP - ${{ env.BRANCH }} (JIT)"
211+ PHP_ID=php_${{ env.ID }}_jit
212+
213+ PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git
214+ PHP_BRANCH=${{ env.BRANCH }}
215+ PHP_COMMIT=${{ env.COMMIT }}
216+
217+ PHP_OPCACHE=${{ env.OPCACHE }}
218+ PHP_JIT=${{ env.JIT }}
219+ EOF
220+
221+ git clone ./php-version-benchmarks/tmp/php_${{ env.ID }}/ ./php-version-benchmarks/tmp/php_${{ env.ID }}_jit
222+ - name : Setup test config
223+ run : |
224+ set -e
225+
99226 cp ./php-version-benchmarks/config/test/1_laravel.ini.dist ./php-version-benchmarks/config/test/1_laravel.ini
100227 cp ./php-version-benchmarks/config/test/2_symfony_main.ini.dist ./php-version-benchmarks/config/test/2_symfony_main.ini
101228 cp ./php-version-benchmarks/config/test/4_wordpress.ini.dist ./php-version-benchmarks/config/test/4_wordpress.ini
@@ -104,6 +231,7 @@ jobs:
104231 - name : Run benchmark
105232 run : ./php-version-benchmarks/benchmark.sh run aws
106233 - name : Store results
234+ if : github.repository == 'kocsismate/php-src' && github.event_name != 'workflow_dispatch'
107235 run : |
108236 set -ex
109237
@@ -119,6 +247,17 @@ jobs:
119247 fi
120248 git commit -m "Add result for ${{ github.repository }}@${{ github.sha }}"
121249 git push
250+ - name : Comment results
251+ if : github.repository != 'php/php-src' && github.event_name == 'workflow_dispatch'
252+ env :
253+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
254+ run : |
255+ PR_NUMBER=$(gh pr list --head "${{ inputs.branch }}" --state open --json number --jq '.[0].number')
256+ if [ ! -z "$PR_NUMBER" ]; then
257+ YEAR="$(date '+%Y')"
258+ NEWEST_RESULT_DIRECTORY=$(ls -td ./php-version-benchmarks/docs/results/$YEAR/*/ | head -1)
259+ gh pr comment $PR_NUMBER --body-file "$NEWEST_RESULT_DIRECTORY/result.md"
260+ fi
122261 - name : Cleanup
123262 if : always()
124263 run : |
0 commit comments