Skip to content

[perf] Add single-process hotspot profiler + performance methodology - #8718

Merged
TomasVotruba merged 1 commit into
mainfrom
worktree-perf-measurement-harness
Oct 19, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
worktree-perf-measurement-harness

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

What

Adds the tooling and written method behind the recent batch of measured perf PRs (#8705-#8714), so the next perf pass starts from data, not guesses.

scripts/rector-hotspot-profile.php

Standalone single-process hotspot profiler. Runs rector process --dry-run over a real project under the Xdebug profiler with parallel disabled (parallel workers each write their own cachegrind and make the numbers useless), parses the cachegrind, and ranks functions two ways:

  • by call count - memoization candidates (a function hit many times on repeating inputs is where a cache might pay)
  • by self cost - where CPU actually burns
php scripts/rector-hotspot-profile.php --project=/path/to/a/real/app --filter='^(Rector|PHPStan)'

Standalone: drives the binary as a subprocess, no autoloader of its own. Docblock documents the two traps found while building it - small corpora are dominated by container bootstrap, and most type/scope cost lives in PHPStan\* not Rector\*.

CLAUDE.md - Performance work section

Short methodology: profile a single-process real run to find the hot spot, qualify a cache candidate by confirming inputs actually repeat and picking a version-safe key (AST mutates to a fixpoint, so node-identity/file-path keys go stale), prove it with CPU-time and call-count A/B rather than wall time, and gate on the full suite plus the order-dependent fixpoint tests.

Why

Keeps the measurement discipline from the perf batch reproducible instead of tribal knowledge.

@TomasVotruba

Copy link
Copy Markdown
Member Author

LGMT 👍

@TomasVotruba
TomasVotruba merged commit 0f82820 into main Oct 19, 2026
48 of 49 checks passed
@TomasVotruba
TomasVotruba deleted the worktree-perf-measurement-harness branch October 19, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant