Performance: skip the syntax-tree rewrite walk for files no rule can affect
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- php
- Lĩnh vực
- performance
Hướng nghiên cứu
Start from SyntaxTreeRewriter::transform(), which walks every transformed file, and NodeRewriterDispatcher, which resolves rules per node class through a closure into getRulesFor(). The proposal adds an optional way for a NodeRewriter (e.g. MagicConstantTransformer) to declare cheap source substrings, then skips the walk when none match. Measure with composer test:performance:transformation, JIT off; done means the rewrite ratio drops while a rule declaring no substrings still always applies.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
SyntaxTreeRewriter walks the whole syntax tree of every transformed file, even when none of the enabled rules can match it. The visitor also finds the rules for each node through a closure call into SyntaxTreeRewriter::getRulesFor().
Measurement
composer test:performance:transformation (JIT off), php-parser corpus of 271 files:
| ms | |
|---|---|
| parse (the main cost of a cache miss) | ~252 |
| plain walk with a no-op visitor | ~26 |
SyntaxTreeRewriter, default rules |
~42 (ratio 1.54) |
SyntaxTreeRewriter, all rules |
~44 (ratio 1.67) |
str_contains pre-check over all sources |
0.4 |
- Only 14 of 271 files contain
__DIR__,__FILE__orgetFileName, which the defaultMagicConstantTransformerrule looks for. Only 16 contain include or require, and 78 containnew. - Caching the rule list per node class inside
NodeRewriterDispatcheralone moved the ratios from 1.53 to 1.42–1.47 (default rules) and from 1.70 to 1.49–1.58 (all rules).
Proposal
- Let a rule declare cheap source substrings that must appear for it to apply, through an optional method or interface. Keep the
NodeRewritercontract compatible for custom rules: a rule without substrings always applies. SyntaxTreeRewriter::transform()skips the walk when no enabled rule's substrings appear in the source, and walks with only the rules whose substrings do.- Inline the rule lookup per node class in
NodeRewriterDispatcher.
Estimate
Cache misses only. With the default rules about 95% of files skip the walk, which saves about 13% of parse plus rewrite time on cache warm-up and debug-mode re-transformations. The rule lookup alone saves 5–8% of the rewriter time. Medium risk (the public NodeRewriter API is touched), medium effort, best done before 4.0.0.
- Ngôn ngữ chính
- PHP
- Star
- 1.7k
- Fork
- 166
- Merge trung bình
- 1 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 30
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của goaop/framework
-
Enhancement PHP-8.6
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Enhancement PHP-8.6 To Be Discussed
Độ khó 4/5 Hơn một tuần Mức phù hợp với người mới 8/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Enhancement PHP-8.6
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Static $__joinPoint keeps the first instance of every woven class aliveCó thể đã có người làm @lisachenko đã nhận 1 ngày trước. Đang mởBug PHP-8.4 PHP-8.5 PHP-8.6
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
Maintainer thường phản hồi trong vòng 1 ngày
-
#[\SensitiveParameter] values leak through joinpoint frames in stack tracesCó thể đã có người làm @lisachenko đã nhận 1 ngày trước. Đang mởBug PHP-8.4 PHP-8.5 PHP-8.6
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của goaop/framework
Issue tương tự
-
bug ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
hashtopolis/server#2614 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
sync-en
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
sync-en
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Перевод устарел
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
-
bug-report bug-report-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
Codeinwp/wp-maintenance-mode#596 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày