Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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
  • Loading branch information
ondrejmirtes and claude committed Sep 23, 2026
commit a1f52c6e0b459ddf175b9adf877f58d12f6aa3df
17 changes: 14 additions & 3 deletions turbo-ext/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,22 @@ drifts ±1s thermally — never run all A then all B):

```bash
bin/phpstan clear-result-cache -c build/phpstan.neon -q
/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
# baseline runs: drop the -d extension= flag. Nothing disables a loaded
# extension, so keep it out of php.ini and load it per run instead
mkdir -p /tmp/turbo-ini && echo "extension=$PWD/turbo-ext/phpstan_turbo.so" > /tmp/turbo-ini/turbo.ini
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
# baseline runs: drop PHP_INI_SCAN_DIR. Nothing disables a loaded extension,
# so keep it out of php.ini and load it per run instead
```

Never load it with `php -d extension=` for a `bin/phpstan` run: when the
OPcache settings are not the ones TurboProcessRestarter wants (OPcache off
for CLI, timestamps validated — the CI images and a default Homebrew PHP
both), PHPStan re-executes itself, and a command-line `-d extension=` does
not survive the restart. The run then measures PHP alone, while
`php -d extension=... -r 'echo phpversion("phpstan_turbo");'` still reports
the version. Confirm with a quantity that must change: user CPU drops by
roughly 40% with the extension really active. (The tests under `tests/`
run no restart, so `-d extension=` is fine there.)

Output identity: `--error-format=raw` runs in both modes must diff empty.

## Zend-level gotchas (each of these cost real debugging time)
Expand Down
8 changes: 5 additions & 3 deletions turbo-ext/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,11 @@ php vendor/bin/phpunit ...

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

## History
Expand Down