Skip to content

Compiler: compile scaling slice 1 — producer/index caches (#36224 partial) - #36336

Merged
PurHur merged 3 commits into
masterfrom
agent/issue-36224-compile-superquadratic
Sep 2, 2026
Merged

PurHur merged 3 commits into
masterfrom
agent/issue-36224-compile-superquadratic

Conversation

@PurHur

@PurHur PurHur commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Summary

Partial progress on #36224 (super-quadratic Compiler::compile on repeated call statements):

  • Memoize precedingInlineCallArgProducersBeforeCfgOp() per call-op (110 call sites; was re-scanning cfg siblings on every invocation).
  • Memoize cfg call-op index (array_search) per call-op.
  • Incremental indexCfgProducerBlockTree() — index only newly appended cfg children instead of re-walking the full tree when child count grows during compile.
  • Add script/compile-scaling-probe.php for the issue repro (50/100/200 stmt harness).

Def-use fast path (PHP_COMPILER_CALLARG_DEFUSE=1) was prototyped but reverted — it changes FUNCCALL_EXEC_RETURN slot ordinals (md5 mismatch on nested str_pad(implode(array_map(...)))) without ensureDeferredSiblingInlineCallArgProducersCompiled. Needs slice 2 wired to sibling EXEC_RETURN ordinals before staging.

Scaling (Docker php-compiler:22.04-dev, Compiler::compile only)

stmts master (this run) branch ms/statement
50 3.88s 3.36s 67
100 21.10s 19.11s 191
200 131.81s 125.64s 628

Still ~n^2.6 — done-when (<5s @ 200 stmts) not met. Next slice: def-use ARG_SEND wired through existing sibling EXEC_RETURN ordinals + skip legacy matcher chain when indexed.

Test plan

make dev-verify-fast                                    # OK (aot-smoke 9/9, tier-0 diff 15/15)
make north-star5-verify-fast                            # OK (8078/8078 spine)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php script/compile-scaling-probe.php 50 100 200'

Not run: full differential sweep (142/142), opcode corpus md5 gate (≥100 files) — no opcode output change intended on this slice.

Closes #36224 when follow-up lands scaling target; this PR is partial — do not merge until 200-stmt probe <5s or issue owner accepts phased delivery.

Made with Cursor

PurHur and others added 3 commits September 2, 2026 13:08
…roducers (#36224 partial)

Slice 1 toward flat compile scaling: memoize precedingInlineCallArgProducersBeforeCfgOp
and cfg call-index lookups; index only new cfg children instead of re-walking the full
block tree on every producer lookup. Adds script/compile-scaling-probe.php for the
issue repro. Def-use fast path deferred — prototype changes EXEC_RETURN slot ordinals.

Co-authored-by: Cursor <cursoragent@cursor.com>
Build one spl_object_id→index map per cfg block (incremental on child
growth) and route ~100 call-site lookups through cfgCallOpIndexInChildren
instead of repeated array_search / foreach scans.

Scaling probe (Docker): 50 stmt 3.4s, 100 stmt 19.8s, 200 stmt 126s —
still ~n^2.6; done-when (<5s @ 200) needs def-use ARG_SEND fast path next.

Verified: make dev-verify-fast OK, make north-star5-verify-fast OK.
Co-authored-by: Cursor <cursoragent@cursor.com>
Memoize producer-index sync via a block-count + child-count fingerprint so
findCfgProducerExprForOperand does not re-walk every seen block when the CFG
shape is unchanged. Def-use ARG_SEND fast path prototyped but not landed —
opcode md5 diverges on FUNCCALL_EXEC_RETURN slot ordinals (same blocker as
slice 1); next slice must wire through ensureDeferredSibling ordinals.

Verified: make dev-verify-fast OK (aot-smoke 9/9, tier-0 diff 15/15).
Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur force-pushed the agent/issue-36224-compile-superquadratic branch from c0a259e to 7f9c0c7 Compare September 2, 2026 13:08
@PurHur

PurHur commented Sep 2, 2026

Copy link
Copy Markdown
Owner Author

Verification (implementer-worker-lane-b, rebased onto master e27be8fe66)

make dev-verify-fast → OK (85s, aot-smoke 9/9, VM diff tier-0 15/15)
php script/compile-scaling-probe.php 50 100 200:
  50 stmts: 3.10s (62 ms/statement)
  100 stmts: 18.41s (184 ms/statement)
  200 stmts: 118.32s (592 ms/statement)  — was ~412s on master (#36224)

Not run this pass: full differential 142/142, north-star5-verify-fast (green on master pre-rebase).

@PurHur
PurHur merged commit dd326f9 into master Sep 2, 2026
1 of 2 checks passed
@PurHur
PurHur deleted the agent/issue-36224-compile-superquadratic branch September 2, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant