Performance: WeavingTransformer reflects every ancestor of every class for the Aspect check (−12% warmup, spurious warmup failures)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- php
- Ambito
- backend, performance
Direzione di ricerca
Leggi src/Instrument/Transformer/WeavingTransformer.php, in particolare il controllo di Aspect alla riga 103 e il ritorno anticipato empty($advices) intorno alla riga 140. Esegui prima i test di trasformazione esistenti, poi aggiungi un test per una classe non corrispondente la cui classe genitore non può essere individuata. Il lavoro è completato quando gli aspects restano non tessuti, quella classe viene registrata come non trasformata senza eccezioni e il test di trasformazione delle prestazioni ha esito positivo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
WeavingTransformer::transform() skips aspects with
if ($class->isInterface() || in_array(Aspect::class, $class->getInterfaceNames(), true)) {
(src/Instrument/Transformer/WeavingTransformer.php:103), and it does this for every class in every file, before advice matching.
In parser-reflection, getInterfaceNames() collects interfaces recursively: it builds a ReflectionClass for the parent, each trait and each interface, and parses their files with ReflectionEngine::parseClass() when they are not loaded yet. So even a class that no advisor matches pays for reflecting, and often parsing, its whole ancestor tree.
It also fails the file when an ancestor cannot be located, which happens with optional dependencies, for example a PHPStan rule or a Symfony DI compiler pass in a package whose dependency is not installed. Such files are never woven, so the failure is spurious. cache:warmup:aop still reports them as errors and exits 1, which blocks a deploy.
Measurement
Cold cache:warmup:aop over vendor/ (3,935 files, two name-based advisors), PHP 8.5, JIT off:
| warmup | errors | |
|---|---|---|
| current | 9.3 s | 99 |
| Aspect check removed (upper bound) | 8.1 s | 7 |
92 of the 99 errors were Class PHPStan\Rules\Rule was not found by locator and similar, all raised by this check.
Proposal
- Keep the cheap
isInterface()skip where it is. - Move the Aspect check into
processSingleClass(), after theempty($advices)early return (:140). Unadvised classes then never reflect their ancestors, and aspects are still never woven. - Optionally, check
implementsInterface(Aspect::class)only once advices were found.
Acceptance
- Aspects are still never woven (existing tests).
- A test: a file with a class whose parent cannot be located and that no advisor matches is recorded as untransformed, with no exception.
composer test:performance:transformationbefore and after:WeavingTransformeris touched.
Estimate
About −12% cold warmup in this setup, and no more spurious warmup failures for unadvised classes with ancestors that cannot be resolved. Low risk, small change.
- Lingua principale
- PHP
- Stelle
- 1.7k
- Fork
- 166
- Merge medio
- 10h
- PR unite (30g)
- 35
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
-
Performance: INTERCEPT_INCLUDES serves untransformed included files through php://filter in production (no opcache)Forse già presa @lisachenko l’ha presa 1 giorno fa. ApertaEnhancement Performance
Difficoltà 4/5 3-5 giorni Idoneità per principianti 56/100
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
Tutte le issue di goaop/framework
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
WordPress/two-factor#1022 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Messenger
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
symfony/symfony-docs#23237 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
glpi-project/glpi#25883 ·
I maintainer di solito rispondono entro 1 giorno
-
sync-en
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
sync-en
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 4 giorni