Repository navigation
perf: two formatting-heavy hostile inputs parsed slower than in Lexbor - #84
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
noahs_ark_matches_attributes_in_any_ordertest 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.