Performance: rewrite only the `new` expressions an `initialization(...)` pointcut can match
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- php
- Área
- backend, performance
Línea de trabajo
Start with ConstructorExecutionTransformer and its $sourceMarkers logic, then trace how AdvisorIndex represents initialization pointcut class filters and how woven files track aspect and kernel resources. Add focused transformer tests for unrelated, matching, subclass, non-reducible, and dynamic new expressions; done means unrelated classes remain native while the existing initialization tests still pass. Compare transformation performance on a woven file with many unrelated constructions before and after.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Split from #818, part 3 (the optional transformer prefilter). Parts 1–2 shipped in #828.
Problem
While at least one initialization(...) pointcut is registered, ConstructorExecutionTransformer rewrites every new Foo(...) in every woven file into ConstructorExecutionTransformer::construct(...). The rule is all-or-nothing: $sourceMarkers returns ['new'] as soon as AdvisorIndex::hasPointcutKind(Pointcut::KIND_INIT) is true. One initialization(App\Domain\Order) pointcut is enough to route the new of every class in the application through the transformer.
#828 made the runtime side cheaper: the per-class strategy cache, and a native new for instantiable classes without initialization advices. The remaining cost is still there for every rewritten new of an unrelated class.
new of a class no pointcut matches |
ns per new (PHP 8.5, JIT off) |
|---|---|
native new |
~64 |
| rewritten, public constructor (after #828) | ~193 |
| rewritten, private/protected constructor, abstract, enum | ~500 (still the advice-less ReflectionConstructorInvocation) |
The rewrite also makes woven sources and stack traces noisier (an extra transformer frame per new).
Proposal
Rewrite only the new expressions whose class can match one of the registered initialization pointcuts, and keep the others native.
When the rewrite stays:
- Resolve the class name of each
newat transform time (the name resolver already runs). - Keep the rewrite for every
newwhose class can't be decided statically:new $class,new static,new self/new parentwhere the target is unknown, and anonymous classes as today.
Pointcut side: a small, conservative API.
- The initialization class filters are namespace patterns:
App\Domain\*,**,Foo|Bar. - A filter like
Foo+also matches subclasses and can't be decided by name. The same goes for an expression combined with other pointcuts in a way that can't be reduced to class-name patterns (!,&&withwithin(...), references). - A pointcut of that kind answers "may match anything", and the transformer then keeps rewriting every
new, as today. - Compare #747 and #821, which hit the same need for a name-part API.
Caching: the decision belongs to the woven file. A changed set of initialization pointcuts must re-weave affected files. Check that aspect and kernel changes already invalidate woven files through the tracked resources, the same way any advice change does.
Acceptance
- With an unrelated
initialization(...)pointcut registered,newof a class that can't match stays a nativenewin the woven source: snapshot or unit test onConstructorExecutionTransformer. - Classes that can match,
+subclass filters, non-reducible expressions and dynamicnewkeep the current rewrite, with identical behaviour in the existing initialization tests. - A benchmark of a woven file with many
newof unrelated classes, before and after. composer test,composer analyze,composer test:performance:transformation(the transformer changes, so CI compares head with base).
Scoring
| Score | Why | |
|---|---|---|
| Effort | Medium | A pointcut-side "class name may match" API that is conservative for +, !, && and references, plus the per-new decision in the transformer, snapshot tests and the transformation-performance run. No runtime or format change. |
| Impact | Low–Medium | Applications without initialization(...) pointcuts gain nothing. With one, every new of an unrelated class saves ~130 ns, or ~430 ns for classes with a non-public constructor, abstract classes and enums, and woven sources lose the extra frame. It only matters for code that creates many objects in woven files. |
Priority Low: #828 already removed most of the cost on the hot path.
- Lenguaje dominante
- PHP
- Estrellas
- 1.7k
- Forks
- 166
- Merge medio
- 1 d 1 h
- PR fusionados (30 d)
- 38
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de goaop/framework
-
Enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
cache:warmup:opcache runs out of memory with the default memory_limit (128M) on larger applicationsAbiertoBug
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Los mantenedores suelen responder en 1 día
-
Bug To Be Discussed
Dificultad 5/5 Más de una semana Aptitud para principiantes 28/100
Los mantenedores suelen responder en 1 día
-
Bug
Dificultad 4/5 1-2 días Aptitud para principiantes 56/100
Los mantenedores suelen responder en 1 día
-
Bug
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
Los mantenedores suelen responder en 1 día
Todos los issues de goaop/framework
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Include flows spanning the full report time windowPosiblemente ocupada @somethingwithproof la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Cacti/plugin_flowview#306 ·
Los mantenedores suelen responder en 1 día
-
priority:low type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
crazy-goat/workerman-bundle#1189 ·
Los mantenedores suelen responder en 1 día
-
Captured slideshow pass overwrites the route path, aborting compose with a rebind() TypeErrorAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Automattic/blocks-engine#5003 ·
Los mantenedores suelen responder en 1 día
-
from-cloud mythic tracked
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
MythicalLTD/FeatherPanel#459 · 1 comentario ·
Los mantenedores suelen responder en 1 día