Parsing document with a lot of HTML tags is slow
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- html, php
- 領域
- performance
調査の方向性
提供された1.5MBのHTMLケースを再現し、HTML5.phpとParser/Tokenizer.phpを通るパーサーパスを追跡します。特にconsumeData()、tagOpen()、tagName()、および433行目付近のDOMTreeBuilder.phpを確認します。生成された入力が大きくなるにつれて実行時間を比較します。解析結果を変更せずに、非線形な低速化を特定して修正できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
I have a script that generates a HTML sample that is ~1.5MB in size. It emulates a real-world example. Then I parse it.
$html = '<HTML><BODY>';
$lines = 20000;
while ($lines--) {
$html .= '<P DIR=LTR><SPAN LANG="en-gb"><FONT FACE="Consolas">>> </FONT></SPAN></P>';
}
$html5 = new Masterminds\HTML5();
$node = $html5->loadHTML($html);
and here's the result:
PHP Fatal error: Maximum execution time of 120 seconds exceeded in vendor/masterminds/html5/src/HTML5/Parser/DOMTreeBuilder.php on line 433
PHP Stack trace:
PHP 1. {main}() test.php:0
PHP 2. Masterminds\HTML5->loadHTML() test.php:23
PHP 3. Masterminds\HTML5->parse() vendor/masterminds/html5/src/HTML5.php:98
PHP 4. Masterminds\HTML5\Parser\Tokenizer->parse() vendor/masterminds/html5/src/HTML5.php:174
PHP 5. Masterminds\HTML5\Parser\Tokenizer->consumeData() vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php:89
PHP 6. Masterminds\HTML5\Parser\Tokenizer->tagOpen() vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php:132
PHP 7. Masterminds\HTML5\Parser\Tokenizer->tagName() vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php:284
PHP 8. Masterminds\HTML5\Parser\DOMTreeBuilder->startTag() vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php:388
I tested this with 2.7.0 and some older versions with no success. The sample half of that size works, but it takes 27 seconds to finish (so it's not linear).
Cross-ref: https://github.com/roundcube/roundcubemail/issues/7331
- 主要言語
- HTML
- スター
- 1.8k
- フォーク
- 123
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Masterminds/html5-php のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
Masterminds/html5-php#280 ·
-
Template contents participate in the DOM tree対応中かも @eyupcanakman が 212 日前に担当しました。 オープンhelp-wanted
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
Masterminds/html5-php#252 · コメント 1 件 · リアクション 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
Masterminds/html5-php#251 ·
-
Parser remove the single < (less than) character from given html string対応中かも @bsweeney が 797 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
Masterminds/html5-php#250 · コメント 5 件 · リアクション 2 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 28/100
Masterminds/html5-php#246 · コメント 1 件 ·
Masterminds/html5-php の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 60/100
メンテナーはふだん 1 日以内に返信
-
Re-importing a cached module re-reads its files once per import path (very slow on Windows / in the LSP)対応中かも @bfren が今日担当しました。 オープンstatus:needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
nushell/nushell#19226 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
type/automation type/performance
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
Permissioned transactions fetch each entity once per tx-step, producing huge permission-check queries対応中かも @verveguy が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信