Skip to content

Commit 3a40a06

Browse files
committed
Default native PHP variant benchmarks to Wasmtime async
1 parent 41e771b commit 3a40a06

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

packages/playground/cli-native/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,8 @@ For example:
315315
VARIANTS="light-48:48MB:emmalloc:WITH_GD=no,WITH_MYSQL=no,WITH_IMAGICK=no" \
316316
bash packages/playground/cli-native/scripts/benchmark-php-wasm-variants.sh
317317
```
318+
319+
The helper defaults to `PHP_WASM_RUNTIME=wasmtime-async` and passes
320+
`WITH_WASMTIME_ASYNC=yes` so native CLI variant runs match the Wasmtime async
321+
runtime. Set `PHP_WASM_RUNTIME=asyncify` only when intentionally comparing the
322+
older asyncify payload.

packages/playground/cli-native/scripts/benchmark-php-wasm-variants.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ WARMUPS="${WARMUPS:-2}"
1212
BASE_PORT="${BASE_PORT:-10100}"
1313
PORT_STEP="${PORT_STEP:-20}"
1414
PACKAGE_PRECOMPILE_WASMTIME="${PACKAGE_PRECOMPILE_WASMTIME:-1}"
15+
PHP_WASM_RUNTIME="${PHP_WASM_RUNTIME:-wasmtime-async}"
1516
KEEP_VARIANT_ARTIFACTS="${KEEP_VARIANT_ARTIFACTS:-0}"
1617
DRY_RUN="${DRY_RUN:-0}"
1718
WORK_DIR="${WORK_DIR:-}"
@@ -36,6 +37,7 @@ Environment:
3637
BASE_PORT=10100
3738
PORT_STEP=20
3839
PACKAGE_PRECOMPILE_WASMTIME=1
40+
PHP_WASM_RUNTIME=wasmtime-async
3941
KEEP_VARIANT_ARTIFACTS=0
4042
WORK_DIR=/tmp/wp-native-variant-bench
4143
DRY_RUN=0
@@ -90,6 +92,14 @@ case "$PACKAGE_PRECOMPILE_WASMTIME" in
9092
;;
9193
esac
9294

95+
case "$PHP_WASM_RUNTIME" in
96+
wasmtime-async | asyncify) ;;
97+
*)
98+
echo "error: PHP_WASM_RUNTIME must be wasmtime-async or asyncify" >&2
99+
exit 1
100+
;;
101+
esac
102+
93103
major="${PHP_VERSION%%.*}"
94104
minor="${PHP_VERSION#*.}"
95105
minor="${minor%%.*}"
@@ -117,7 +127,7 @@ write_asset_manifest() {
117127
cat >"$manifest_path" <<JSON
118128
{
119129
"schemaVersion": 1,
120-
"runtime": "node-builds/asyncify",
130+
"runtime": "node-builds/$PHP_WASM_RUNTIME",
121131
"php": {
122132
"$php_selector_version": {
123133
"js": {
@@ -148,7 +158,7 @@ build_variant_asset_root() {
148158
local malloc="$3"
149159
local extra_csv="${4:-}"
150160
local asset_root="$WORK_DIR/$label/asset-root"
151-
local output_dir="$asset_root/packages/php-wasm/node-builds/$version_dir/asyncify"
161+
local output_dir="$asset_root/packages/php-wasm/node-builds/$version_dir/$PHP_WASM_RUNTIME"
152162
local build_args=(
153163
"$REPO_ROOT/packages/php-wasm/compile/build.js"
154164
"--PLATFORM=node"
@@ -157,6 +167,9 @@ build_variant_asset_root() {
157167
"--INITIAL_MEMORY=$initial_memory"
158168
"--MALLOC=$malloc"
159169
)
170+
if [[ "$PHP_WASM_RUNTIME" == "wasmtime-async" ]]; then
171+
build_args+=("--WITH_WASMTIME_ASYNC=yes")
172+
fi
160173

161174
if [[ -n "$extra_csv" ]]; then
162175
local extra_args=()
@@ -172,8 +185,8 @@ build_variant_asset_root() {
172185
printf "node"
173186
printf " %q" "${build_args[@]}"
174187
printf "\n"
175-
printf "PACKAGE_ASSET_ROOT=%q WASMTIME_LABEL=%q PHP_VERSION=%q WP_VERSION=%q SAMPLES=%q WARMUPS=%q BASE_PORT=<port> PACKAGE_PRECOMPILE_WASMTIME=%q bash %q\n" \
176-
"$asset_root" "$label" "$php_selector_version" "$WP_VERSION" "$SAMPLES" "$WARMUPS" "$PACKAGE_PRECOMPILE_WASMTIME" "$BENCHMARK_SCRIPT"
188+
printf "PACKAGE_ASSET_ROOT=%q WASMTIME_LABEL=%q PHP_VERSION=%q WP_VERSION=%q SAMPLES=%q WARMUPS=%q BASE_PORT=<port> PACKAGE_PRECOMPILE_WASMTIME=%q PHP_WASM_RUNTIME=%q bash %q\n" \
189+
"$asset_root" "$label" "$php_selector_version" "$WP_VERSION" "$SAMPLES" "$WARMUPS" "$PACKAGE_PRECOMPILE_WASMTIME" "$PHP_WASM_RUNTIME" "$BENCHMARK_SCRIPT"
177190
return 0
178191
fi
179192

0 commit comments

Comments
 (0)