Skip to content

Speed up inventory lint: opt-in fast frontend patches + parallel cached bin/lint.php (#16077)#16394

Open
PurHur wants to merge 2 commits into
masterfrom
feat/16077-frontend-perf
Open

Speed up inventory lint: opt-in fast frontend patches + parallel cached bin/lint.php (#16077)#16394
PurHur wants to merge 2 commits into
masterfrom
feat/16077-frontend-perf

Conversation

@PurHur

@PurHur PurHur commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Fixes #16077 (the 2h+ inventory lint gate).

Vendored-frontend algorithmic fixes (patches/)

  • php-cfg-simplifier-use-chain.patchSimplifier::replaceVariables via the operand's recorded usages/write-ops instead of re-walking the whole CFG per removed phi: O(phis×blocks) → O(uses), 121s → 0.8s on lib/Compiler.php. Opt-in PHPCFG_SIMPLIFIER_USECHAIN=1.
  • php-types-resolver-worklist.patchTypeReconstructor::resolve() as a dependency-driven worklist instead of full re-scan rounds: types phase 40s → 7s. Opt-in PHPTYPES_RESOLVER_WORKLIST=1.
  • php-cfg-operand-usage-dedup.patch — O(1) addUsage/addWriteOp dedup via spl_object_id sets (always on; pure dedup, no ordering change).

⚠️ The two order-changing paths are opt-in, default legacy: resolution/replacement order is observable in AOT codegen (phi operand types — check-aot-build-smoke tier 1 caught it during validation, exactly the failure class it was built for). bin/lint.php enables them via putenv for lint workloads only, where output equivalence is proven: identical issues on lib/VM.php, lib/Compiler.php, lib/JIT.php, and a full 4037-file inventory cold run matching the committed table. PHP_COMPILER_LINT_FRONTEND_FAST=0 opts lint back out.

Parallel + cached inventory lint (bin/lint.php)

  • Per-file result cache (build/lint-cache/, keyed by file sha1 + linter fingerprint over lint.php/Linter.php/composer.lock/unsupported-syntax.md); PHP_COMPILER_LINT_CACHE=0 opts out.
  • Worker fan-out (--worker-stdin, PHP_COMPILER_LINT_JOBS, default nproc−2); any file a worker fails to report is re-linted inline so a crash cannot drop findings.

Measured (pinned container)

inventory lint before after
cold 2h+ sequential 50m10s (6 jobs)
warm re-run 2h+ 0.47s
single file (lib/Compiler.php) 7m03s 1m44s

Verified: patches apply cold from pristine vendor and skip idempotently; check-aot-build-smoke rc=0 with default paths; VMTest-tier equivalence via identical lint output legacy vs fast.

🤖 Generated with Claude Code

anmichels and others added 2 commits July 5, 2026 13:45
…ed bin/lint.php (#16077).

Three vendored-frontend algorithmic fixes, shipped as patches/ (diffed
against the fully-patched files, applied last by apply-patches.sh):

- php-cfg-simplifier-use-chain.patch: Simplifier::replaceVariables via
  the operand's recorded usages/write-ops instead of re-walking the
  whole CFG per removed phi (O(phis x blocks) -> O(uses); 121s -> 0.8s
  on lib/Compiler.php). Opt-in: PHPCFG_SIMPLIFIER_USECHAIN=1.
- php-types-resolver-worklist.patch: TypeReconstructor::resolve() as a
  dependency-driven worklist instead of full re-scan rounds (types
  phase 40s -> 7s on lib/Compiler.php). Opt-in: PHPTYPES_RESOLVER_WORKLIST=1.
- php-cfg-operand-usage-dedup.patch: addUsage/addWriteOp O(1) dedup via
  spl_object_id sets instead of linear scans (always on — pure dedup,
  no ordering change).

The two order-changing paths are OPT-IN, defaulting to the legacy
walks: resolution/replacement ORDER is observable in AOT codegen (phi
operand types — caught by check-aot-build-smoke tier 1 before this PR
went up). bin/lint.php turns them on for lint workloads via putenv,
where output equivalence is proven: identical lint issues on
lib/VM.php, lib/Compiler.php, lib/JIT.php + the full 4037-file
inventory cold run matching the committed table.
PHP_COMPILER_LINT_FRONTEND_FAST=0 opts lint back out.

bin/lint.php --bootstrap-inventory also gains a per-file result cache
(build/lint-cache/, keyed by file sha1 + linter fingerprint) and
parallel worker fan-out (--worker-stdin, PHP_COMPILER_LINT_JOBS,
default nproc-2), with inline re-lint of any file a worker fails to
report. PHP_COMPILER_LINT_CACHE=0 opts out.

Inventory gate measured in the pinned container: sequential 2h+ ->
50m10s cold (6 jobs) -> 0.47s warm re-run.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…#16354 fixed).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@PurHur PurHur force-pushed the feat/16077-frontend-perf branch from 9790223 to fcc65c7 Compare July 5, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants