ClassPublisher fold proof re-parses every selector per fold group (dominates compose; deadline failures after all pages compile)

オープン
#7,575 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php
領域
performance

調査の方向性

Start in ClassPublisher::publish(), then trace folds(), foldPreservesCascade(), and selector parsing through cascadeSelectors() and CssSelectorMatcher::parse(). Compare the published output and profiling results against the captured 5-page and 50-page plans; done means the output stays byte-identical while repeated selector parsing is reduced. The issue reports that 52 relevant unit test files pass, but names no specific test command.

索引モデルが issue の本文から書いたものです。

説明

Summary

ClassPublisher::publish() dominates compose time on real imports. It is the main reason production imports finish compiling every page and then run past the 3,600 s capture deadline with no further progress (capture_deadline_exceeded). That was 64 failures last week, most with pages_built == pages_to_build.

Local profile of a 50-page Shopify import (SSI 1.39.38, compose split with extra StepTimer marks):

compose step time
ClassPublisher::publish 277 s of 384 s total compose
everything else 107 s

Cause

folds() calls foldPreservesCascade($sheets, $map) once per candidate fold group. Each call:

  1. re-splits every stylesheet (cssPieces + CssValueSplitter::splitTopLevel);
  2. runs renamedPrelude() on every selector; and
  3. parses every selector twice with CssSelectorMatcher::parse() (before and after). This includes selectors that name none of the folded classes, whose text and weight cannot change.

Measured on the pre-publish plans, which have 39k–43k selectors: 2–40 fold groups mean up to about 3.4M selector parses. Some of those are long :where()/:is() lists, where parseCompound/matchingClose dominate.

Fix (prototyped, output byte-identical)

  • Read the selectors once per publish (cascadeSelectors()): each selector's text and the class tokens it names.
  • In foldPreservesCascade(), skip selectors whose classes don't intersect the map. Only rename and re-weigh the ones that do.
  • Weigh specificity lazily, memoized per selector. The full weight list is only needed when a fold changes specificity, which is the existing conservative pairwise proof and stays unchanged.

Offline ClassPublisher::publish() on the two captured pre-publish plans, current trunk versus the patch:

plan trunk patch output
5-page site 75 s 4.2 s sha256(serialize($published)) identical
50-page site 67 s 19 s identical

All 52 tests/unit files touching ClassPublisher, class namespaces or folds pass.

主要言語
PHP
スター
31
フォーク
7
平均マージ
7時間 50分
マージ済み PR(30日)
822

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Automattic/blocks-engine のほかの issue

Automattic/blocks-engine の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。