Skip to content

bench: nothing timed Parsec against Lexbor's own C - #69

Merged
jamesconwaydev merged 2 commits into
mainfrom
bench-lexbor
Nov 15, 2026
Merged

jamesconwaydev merged 2 commits into
mainfrom
bench-lexbor

Conversation

@jamesconwaydev

Copy link
Copy Markdown
Collaborator

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.
  • Parsec, Lexbor and html5ever 0.40.1 (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.
  • Peak memory: one counting global allocator, and Lexbor's malloc/realloc/calloc/free are routed through it with lexbor_memory_setup, so all three are counted the same way.
  • Corpus: 13 real pages pinned as Internet Archive snapshots with SHA-256 hashes (bench/pages.txt, downloaded by bench/fetch-pages.sh, never committed), 1 MB and 10 MB generated shop listings, and the eight inputs from examples/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.
  • CI gets a bench job on Ubuntu: fmt, clippy, cargo-deny and a run on the generated pages.
  • README: the speed paragraph now gives these numbers, wins and losses both. The wiki's Benchmarks page gets the method and every number once this merges.

Results (Apple M2 Max, two runs, within 5% of each other)

  • All 13 real pages, 24.4 MB: Parsec 370 MB/s, Lexbor 242, html5ever 82 (1.53×). Parsec is ahead on every page, by 1.44× to 2.65×, and holds less memory than Lexbor on each.
  • Shop listings: 2.0× at both sizes.
  • Hostile: 80,000 unclosed <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 sources on bench/ are clean.
  • scripts/check-headers.sh passes.
  • The bench runs with an empty bench/corpus/ when only generated or hostile pages are named, as CI does.

Fixes #2

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).
@jamesconwaydev jamesconwaydev added this to the M1. Proof milestone Nov 15, 2026
@jamesconwaydev jamesconwaydev added the bench Benchmarks against Lexbor and others label Nov 15, 2026
@jamesconwaydev
jamesconwaydev enabled auto-merge (squash) November 15, 2026 21:44
@jamesconwaydev
jamesconwaydev merged commit 4728398 into main Nov 15, 2026
12 checks passed
@jamesconwaydev
jamesconwaydev deleted the bench-lexbor branch November 15, 2026 21:46
@github-project-automation github-project-automation Bot moved this from Todo to Done in Parsec roadmap Nov 15, 2026
@jamesconwaydev jamesconwaydev mentioned this pull request Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bench Benchmarks against Lexbor and others

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Benchmark Parsec against Lexbor's own C in one process

1 participant