Performance: rewrite only the `new` expressions an `initialization(...)` pointcut can match
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- php
- 領域
- backend, performance
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- PHP
- スター
- 1.7k
- フォーク
- 166
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 42
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
goaop/framework のほかの issue
-
Enhancement Performance To Be Discussed
難易度 5/5 1週間以上 初心者へのやさしさ 28/100
goaop/framework#814 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`PREBUILT_CACHE` weaves and writes the cache when a class is missing from it (fails on read-only file systems)対応中かも @lisachenko が今日担当しました。 オープンBug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
Enhancement PHP-8.6
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
Enhancement PHP-8.6 To Be Discussed
難易度 4/5 1週間以上 初心者へのやさしさ 8/100
メンテナーはふだん 1 日以内に返信
-
Enhancement PHP-8.6
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
メンテナーはふだん 1 日以内に返信
goaop/framework の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
FinanceFlash/unvibecode#577 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
Eyevinn/php-runner#24 ·
-
Administration: required plugin configuration field stays invalid after restoring its saved valueオープンneeds-triage Platform(Default)
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 87/100
octobercms/october#6153 ·
-
good first issue priority:low type:docs
難易度 1/5 1〜3時間 初心者へのやさしさ 95/100
crazy-goat/rabbit-stream#969 ·
メンテナーはふだん 1 日以内に返信