Performance: proxy generators print, re-parse and re-print every generated method body
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- php
- Ambito
- performance
Direzione di ricerca
Read the listed entry points in InterceptorListGenerator.php, MethodGenerator.php, FunctionGenerator.php, the proxy generators, WeavingTransformer.php, and AttributeGroupsGenerator.php; compare them with the AST-based hooks in InterceptedPropertyGenerator. Run the weaving fixture snapshot tests and composer test:performance:transformation before and after. Done means snapshots remain byte-identical, DebugWeavingCommand has no warm-up differences, and the benchmark confirms the performance change.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
Generating the body of each intercepted method or function takes a lex, an LR parse and two pretty-prints:
new InterceptorListGenerator(...)->generate()creates anew GeneratedCodePrinterper call (src/Proxy/Generator/InterceptorListGenerator.php:97) and prints the interceptor list to a string. Call sites:ClassProxyGenerator.php:353, 409, 434EnumProxyGenerator.php:243TraitProxyGenerator.php:157FunctionProxyGenerator.php:132
- The string is put into a heredoc body. The setter parses that string back into an AST:
self::getParser()->parse('<?php ' . $value)inMethodGenerator.php:103andFunctionGenerator.php:79. ClassGeneratorandFunctionGeneratorthen print the whole class or function again.
Smaller work is also repeated per intercepted method:
- Linear method lookups: parser-reflection's
hasMethod()andgetMethod()scan all methods. They are called several times per intercepted method:WeavingTransformer.php:594, 598,ClassProxyGenerator.php:123(twice),:219,:273, and the same in the Enum and Trait generators. That is O(k·M) scans for a class with k intercepted methods out of M. - Wasted type render:
ClassProxyGenerator.php:354renders the return type through reflection withTypeGenerator::renderTypeForPhpDoc($method->getReturnType()), then:356-362overwrites it from the AST node, which always exists during weaving. The same AST → ReflectionType → AST round trip happens for parameter and return types inMethodGeneratorandParameterGenerator, althoughTypeGenerator::fromAstNode()exists. - Attribute copying:
AttributeGroupsGenerator.php:181-198builds anew NodeTraverserwith an anonymous visitor class for every copied attribute, even one without arguments. The anonymous class also breaks the AGENTS.md rule "no anonymous classes in src/".
Proposal
- Method bodies: build them as AST directly. That means a
Static_statement for$__joinPointwith its@vardoc comment, theInterceptorInjector::for*()call built fromInterceptorListGenerator::getNode(), and aReturn_orExpressionfor the__invoke. The generators then set statements instead of a code string.InterceptedPropertyGeneratoralready builds its hooks this way, andGeneratedCodePrinteralready produces the multi-line layout from the AST. - Method lookups: build a name → method map once per woven class and share it between WeavingTransformer and the generators.
- Types: take the AST path first and fall back to reflection only when no node is available.
- Attributes: use a named
final@internalvisitor, created once, and skip the traversal when the attribute has no arguments.
Acceptance
- Generated proxies stay byte-identical: the existing snapshot tests of the weaving fixtures, and the double warm-up of
DebugWeavingCommandstays free of differences. composer test:performance:transformationbefore and after: the weaving case covers proxy generation.
Estimate
Roughly 30–50% of proxy-generation time per intercepted method (estimate from reading the code, to be confirmed by the weaving benchmark). Low to medium risk, medium change.
- Lingua principale
- PHP
- Stelle
- 1.7k
- Fork
- 166
- Merge medio
- 19h 39m
- PR unite (30g)
- 48
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di goaop/framework
-
Enhancement Performance
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
goaop/framework#747 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Enhancement Performance To Be Discussed
Difficoltà 3/5 Mezza giornata Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
Feature
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
-
Bug Known Issue
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
goaop/framework#696 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 5/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di goaop/framework
Issue simili
-
Impact: Medium Level: Easy Type: Bug Value: Users
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
vigetlabs/wordpress-site-starter#315 ·
I maintainer di solito rispondono entro 15 giorni
-
PHP 8.6: bundled guzzlehttp/promises loads class `Is` → "Using "is" as a class name is deprecated"Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
google/site-kit-wp#14004 ·
I maintainer di solito rispondono entro 2 giorni
-
Awaiting Triage bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
jwage/phpamqplib-messenger#159 ·