Skip to content

perf: two formatting-heavy hostile inputs parsed slower than in Lexbor - #84

Merged
jamesconwaydev merged 1 commit into
mainfrom
formatting-speed
Nov 19, 2026
Merged

jamesconwaydev merged 1 commit into
mainfrom
formatting-speed

Conversation

@jamesconwaydev

Copy link
Copy Markdown
Collaborator

Problem

Two of the eight hostile inputs in the bench went Lexbor's way (#68): 300 open <b class=cN> before 3,000 paragraphs (0.56x), and a dozen formatting tags reopened in every paragraph (0.86x). Every new formatting element ran the Noah's Ark check against the whole list of active formatting elements, comparing names and attributes as strings and collecting matches into a new Vec.

Change

Closes #68

Tests

  • html5lib tokenizer 7,045 passed and tree construction 3,898 passed, 0 failed. Netweir's new noahs_ark_matches_attributes_in_any_order test comes with the sync.
  • parsec-html-bench, Apple M2 Max at load under 3, against Lexbor 3.0.1: formatting then paragraphs 68 MB/s vs 29 (2.33x), distinct formatting per p 29 vs 26 (1.11x). The other six hostile inputs, the 13 real pages and the selector table are unchanged.

Syncs Netweir ad9b1fb (netweir/netweir#325). The Noah's Ark check
compared each new formatting element with every entry in the list of
active formatting elements, name by name and attribute by attribute,
and built a Vec of the matches. Each element now carries a cached hash
of its name and attributes, so the scan compares one number per entry.

Against Lexbor 3.0.1: 300 open <b> then 3,000 paragraphs goes from
0.56x to 2.33x, a dozen formatting tags per paragraph from 0.86x to
1.11x. Parsec is now ahead on all eight hostile inputs.
@jamesconwaydev
jamesconwaydev enabled auto-merge (squash) November 19, 2026 01:58
@jamesconwaydev
jamesconwaydev merged commit a2d5d2f into main Nov 19, 2026
23 of 28 checks passed
@jamesconwaydev
jamesconwaydev deleted the formatting-speed branch November 19, 2026 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two formatting-heavy hostile inputs parse slower than in Lexbor

1 participant