Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Performance: WeavingTransformer reflects every ancestor of every class for the Aspect check (−12% warmup, spurious warmup failures)

Chiusa Adatta ai principianti
#748 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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

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

Bug Enhancement Performance

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 the empty($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:transformation before and after: WeavingTransformer is 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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di goaop/framework

Tutte le issue di goaop/framework

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.