Repository navigation
bench: nothing timed Parsec against Lexbor's own C - #69
Merged
Merged
Conversation
A separate bench/ workspace builds Lexbor 3.0.1 from a submodule with CMake and times Parsec, Lexbor and html5ever on the same strings in one process: the median of at least 30 runs, plus peak heap growth, counted by one allocator that Lexbor's malloc goes through as well. The pages are 13 real ones pinned as Internet Archive snapshots with SHA-256 hashes (bench/fetch-pages.sh downloads them), two generated shop listings, and the hostile inputs, which run in child processes with a time limit. CI lints it, checks its licences and runs it on the generated pages.
Replace it with bench/'s numbers: 370 MB/s against Lexbor's 242 and html5ever's 82 over 13 real pages, ahead on every one, and the two hostile inputs where Lexbor is faster (#68).
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
The README's only speed claim came from Netweir's Python benchmark, which times Python and three CSS queries along with the parse. Nothing compared Parsec's parser with Lexbor's own C.
Change
bench/, its own Cargo workspace (so the three-OS test job never builds C), with Lexbor 3.0.1 as a submodule at its release tag, built by CMake with Lexbor's default Release flags. Three FFI calls:lxb_html_document_create,_parse,_destroy.RcDom) parse the same in-memory string with scripting off. Each time is the median of at least 30 runs after three warm-ups; freeing isn't timed.malloc/realloc/calloc/freeare routed through it withlexbor_memory_setup, so all three are counted the same way.bench/pages.txt, downloaded bybench/fetch-pages.sh, never committed), 1 MB and 10 MB generated shop listings, and the eight inputs fromexamples/hostile.rs. Hostile inputs run in child processes with a two-minute limit, so a hang or crash is reported instead of stopping the run.benchjob on Ubuntu: fmt, clippy, cargo-deny and a run on the generated pages.Results (Apple M2 Max, two runs, within 5% of each other)
<div>s take Parsec 3 ms and Lexbor 5.2 s. Two inputs go Lexbor's way, 0.56× and 0.86×; that's Two formatting-heavy hostile inputs parse slower than in Lexbor #68.Tests
cargo fmt,cargo clippy --release -- -D warnings,cargo deny check licenses bans sourcesonbench/are clean.scripts/check-headers.shpasses.bench/corpus/when only generated or hostile pages are named, as CI does.Fixes #2