Skip to content

HTML API: Run analysis and benchmarking in CI - #15302

Draft
dmsnell wants to merge 3 commits into
WordPress:trunkfrom
dmsnell:html-api/commoncrawl-ci
Draft

dmsnell wants to merge 3 commits into
WordPress:trunkfrom
dmsnell:html-api/commoncrawl-ci

Conversation

@dmsnell

@dmsnell dmsnell commented Oct 31, 2026

Copy link
Copy Markdown
Member

Built with Claude code.

Trac ticket: Core-66430

dmsnell and others added 2 commits October 31, 2026 20:09
…cuments.

Adds a workflow which compares how the HTML API parses real-world HTML with and without a pull request. It fetches a fresh batch of documents from the latest CommonCrawl crawl, replays the same batch through the target branch and through the pull request merged into it, and leaves a report as a comment on the pull request.

The report covers:
- Tag Processor and HTML Processor parse times, with totals, per-document deltas, and percentage changes for all, small, medium, and large documents.
- A chart of median parse time by document size for both checkouts, leaving out sizes at either end with too few documents for a meaningful median.
- How many documents the HTML Processor does not support with each checkout, grouped by the reason it stopped and the line it stopped on.
- Which documents became newly supported or unsupported.

The analysis takes a while, so it only runs when the `html-api-commoncrawl` label is added to a pull request which changes the HTML API, or when the workflow is run manually with a pull request number. The label is removed as soon as it is added, so it can be added again to request another analysis. How many documents to fetch, how long to spend fetching them, and how many timing rounds to run are configurable.

Documents are fetched and replayed with a vendored build of cc-analyzer, which is built without its default HTTP identity. The analysis scripts load the HTML API, and what `wp_kses()` needs, from an explicit list of files without loading WordPress, presenting a UTF-8 site at example.com.

The label removal and the comment are handled by a separate `pull_request_target`/`workflow_run` workflow, because workflows triggered by pull requests from forks cannot write to them. It replaces the report from any earlier analysis, searching every page of comments for it. That workflow only runs from the default branch, so it can only be tested after this is merged, or on a fork's default branch.

See #66430.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds `wp_kses( $html, 'post' )` as a third measurement beside the Tag Processor and the HTML Processor. Each document's time is recorded for both checkouts, and the report gains a section for it with the same per-size-group table, chart, and largest slowdowns as the parsers.

Only the files `wp_kses()` needs are loaded, without WordPress's default filters such as those on `pre_kses`, so its times show how a change affects `wp_kses()` itself rather than what a full site would measure. The report notes this.

Since `wp_kses()` is now measured, pull requests which change `kses.php` can also request the analysis.

See #66430.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
name: HTML API CommonCrawl Comments

on:
pull_request_target:
- 'tools/html-api-commoncrawl/**'
- '.github/workflows/html-api-commoncrawl.yml'
- '.github/workflows/html-api-commoncrawl-comment.yml'
workflow_run:
The first run of the CommonCrawl analysis spent half an hour fetching
one WARC file: cc-analyzer re-summed its whole cache before storing
each document, and read every record of the file, though only about a
third are HTML responses.

Rebuild cc-analyzer.phar from a cc-analyzer branch which keeps a
running total of cached bytes, can sample captures from random blocks
of a crawl's URL index, and downloads those records concurrently,
retrying throttled transfers without holding up the others. The fetch
now samples successful `text/html` captures from many hosts across the
whole crawl, downloads only those records four at a time, and retries
transfers which CommonCrawl throttles.

See #66430.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants