Skip to content

Commit a1f52c6

Browse files
ondrejmirtesclaude
andcommitted
Load turbo through PHP_INI_SCAN_DIR in the benchmark protocol
When the OPcache settings are not the ones TurboProcessRestarter wants (OPcache off for CLI in the CI images, validated timestamps on a default Homebrew PHP), PHPStan re-executes itself and a command-line -d extension= does not survive: the run measures PHP alone while php -d extension=... -r still reports the extension's version. On src/Type src/Analyser --debug: 40.0 s user with -d, 17.2 s through PHP_INI_SCAN_DIR. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qi7GRGMn9ZuY2jSc97wqBF
1 parent fc1b0a2 commit a1f52c6

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎turbo-ext/CLAUDE.md‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,22 @@ drifts ±1s thermally — never run all A then all B):
287287

288288
```bash
289289
bin/phpstan clear-result-cache -c build/phpstan.neon -q
290-
/usr/bin/time php -d memory_limit=6G -d extension=$PWD/turbo-ext/phpstan_turbo.so bin/phpstan analyse -c build/phpstan.neon --debug -q src
291-
# baseline runs: drop the -d extension= flag. Nothing disables a loaded
292-
# extension, so keep it out of php.ini and load it per run instead
290+
mkdir -p /tmp/turbo-ini && echo "extension=$PWD/turbo-ext/phpstan_turbo.so" > /tmp/turbo-ini/turbo.ini
291+
PHP_INI_SCAN_DIR=":/tmp/turbo-ini" /usr/bin/time php -d memory_limit=6G bin/phpstan analyse -c build/phpstan.neon --debug -q src
292+
# baseline runs: drop PHP_INI_SCAN_DIR. Nothing disables a loaded extension,
293+
# so keep it out of php.ini and load it per run instead
293294
```
294295

296+
Never load it with `php -d extension=` for a `bin/phpstan` run: when the
297+
OPcache settings are not the ones TurboProcessRestarter wants (OPcache off
298+
for CLI, timestamps validated — the CI images and a default Homebrew PHP
299+
both), PHPStan re-executes itself, and a command-line `-d extension=` does
300+
not survive the restart. The run then measures PHP alone, while
301+
`php -d extension=... -r 'echo phpversion("phpstan_turbo");'` still reports
302+
the version. Confirm with a quantity that must change: user CPU drops by
303+
roughly 40% with the extension really active. (The tests under `tests/`
304+
run no restart, so `-d extension=` is fine there.)
305+
295306
Output identity: `--error-format=raw` runs in both modes must diff empty.
296307

297308
## Zend-level gotchas (each of these cost real debugging time)

‎turbo-ext/README.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,11 @@ php vendor/bin/phpunit ...
572572

573573
# output identity (clear the result cache between runs!)
574574
# nothing disables a loaded extension, so keep it out of php.ini and load it
575-
# per run instead
576-
php -d extension=$(pwd)/phpstan_turbo.so ../bin/phpstan analyse ... --error-format=raw # with
577-
php ../bin/phpstan analyse ... --error-format=raw # without
575+
# per run instead — through PHP_INI_SCAN_DIR, not -d extension=: PHPStan's
576+
# OPcache restart re-executes the process and drops command-line -d flags
577+
mkdir -p /tmp/turbo-ini && echo "extension=$(pwd)/phpstan_turbo.so" > /tmp/turbo-ini/turbo.ini
578+
PHP_INI_SCAN_DIR=":/tmp/turbo-ini" php ../bin/phpstan analyse ... --error-format=raw # with
579+
php ../bin/phpstan analyse ... --error-format=raw # without
578580
```
579581

580582
## History

0 commit comments

Comments
 (0)