Performance: unbounded parser-reflection AST cache during weaving (671 MB peak, −25% parse time when bounded)
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
- 55/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- php
- Ambito
- backend, performance
Direzione di ricerca
Start with src/Instrument/Transformer/WeavingTransformer.php and src/Instrument/Transformer/StreamMetaData.php, then trace how SourceTransformingLoader::ensureRegistered() and CacheWarmer initialize the transformation pipeline. Measure warmup with cache limits of 64, 256, and 1024, and run composer test:performance:transformation; done means woven output is unchanged and the chosen limit has before-and-after time and peak-memory measurements.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
ReflectionEngine::parseFile() (goaop/parser-reflection) keeps the AST of every parsed file in the static ReflectionEngine::$parsedFiles for the life of the process. The framework never calls ReflectionEngine::setMaximumCachedFiles().
Every woven file passes through it (src/Instrument/Transformer/StreamMetaData.php:134), and so does every ancestor reflected during matching. During cache:warmup:aop, and on large cache-miss requests, memory therefore grows with the AST of the whole codebase, and GC and the allocator slow down with it.
One reason the cache cannot simply be bounded today: WeavingTransformer::processSingleClass() reads the original imports through new ReflectionFileNamespace($classFileName, …) (src/Instrument/Transformer/WeavingTransformer.php:158). That call only avoids re-reading and re-parsing the file from disk because the AST cache happens to hit. It also takes the imports of the first block of that namespace when a file has several blocks of the same namespace.
Measurement
ReflectionEngine::parseFile($file, $content) over 3,931 vendor files (14 MB), PHP 8.5, JIT off:
| cache | time | peak memory |
|---|---|---|
| unbounded (current) | 7.35 s | 671 MB |
setMaximumCachedFiles(64) |
5.5 s | 68 MB |
| unbounded, GC disabled | 6.3 s | 671 MB |
| no retention at all (parse + NameResolver only) | 4.8 s | 31 MB |
Proposal
- In
processSingleClass(), read the imports from theReflectionFileNamespacealready being iterated intransform(), and pass it down. This avoids the secondReflectionFileNamespace(tworealpathcalls plus a namespace lookup) and fixes the duplicate-namespace-block case. - Put a limit on the AST cache while weaving, for example
setMaximumCachedFiles(256), set when the transformation pipeline is first brought up (SourceTransformingLoader::ensureRegistered()) and inCacheWarmer. Choose the limit by measurement: parents are re-used across files, so measure warmup with a limit of 64, 256 and 1024. - Optionally, evict the woven file's own AST once its transformation is finished.
Acceptance
- Woven output unchanged.
- A warmup benchmark (time and peak memory) for the chosen limit.
composer test:performance:transformationbefore and after:WeavingTransformerand the loader wiring are touched.
Estimate
About −20–25% parse time and about −90% peak memory during warmup. Low to medium risk, small change.
- Lingua principale
- PHP
- Stelle
- 1.7k
- Fork
- 166
- Merge medio
- 9h 12m
- PR unite (30g)
- 30
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
-
Bug Enhancement Performance
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Performance: cache warmup walks the application tree twice and descends into excluded directoriesApertaEnhancement Performance
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Enhancement Performance
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
-
Enhancement Performance
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
Enhancement Performance
Difficoltà 4/5 3-5 giorni Idoneità per principianti 56/100
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
-
run-fpm-phpt.sh refuses FPMNG_PHPT_PORT_BASE, so the upstream suite cannot use a reserved laneApertaarea:test-harness help wanted priority:low type:chore
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
crazy-goat/php-fpm-ng#913 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
10up/10up-experience#238 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
laravel/nova-issues#7002 ·
-
extension/Commercial needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni