Skip to content

feat(bench): the figures parsec.tools quotes could only be copied by hand - #259

Merged
jamesconwaydev merged 1 commit into
mainfrom
bench-json
Nov 29, 2026
Merged

jamesconwaydev merged 1 commit into
mainfrom
bench-json

Conversation

@jamesconwaydev

Copy link
Copy Markdown
Collaborator

Problem

The bench prints tables and nothing else. So parsec.tools keeps 27 figures typed in by hand from the docs' Benchmarks pages, under two shortcut: comments, and every new run means retyping them and hoping each sentence that cites one still holds.

Change

  • --json PATH works with any mode. Alongside the tables, which don't change, the run writes every figure it printed to PATH: one object per figure, {bench, source, bytes, parser, metric, value}. The file also carries schema (1), date, args, commit, rustc, machine (CPU, cores, memory, OS, arch), load_average when the run ended, and each parser's versions. The format is in bench/src/results.rs, and build.rs adds the cssparser and rustc versions to what it already passes in.
  • Metrics: seconds (median), peak_bytes, ns_per_url, p50_seconds to slowest_seconds, seconds_per_1000_pages, disagrees_with_parsec, crashes, timeouts, refused, no_document and pages. Real pages are html, generated ones html-generated and hostile ones html-hostile, so a site can count each set on its own.
  • bench/results/2026-11-29-m2-max/ holds a full run with it, one file per mode: pages.json (HTML, selectors, URLs, CSS), decode.json, js.json, js-lex.json, boss.json and realworld.json. It ran on an M2 Max, macOS 26.7.3, Rust 1.100, at 72d32f0, with the one-minute load between 1.8 and 3.2 as each mode finished.
  • bench/realworld.tsv is a fresh fetch. Most pages on the 21 November list have changed since, and fetch-realworld.sh keeps only pages whose hash still matches, so a run on the old list would have covered a few hundred pages. fetch-realworld.sh --urls fetched Netweir's 2,709 URLs again: 1,746 kept, 563.4 MB. The other 963 were refused by robots.txt (99), unreachable (562), returned a non-200 status (298) or weren't HTML (4).

What the new run says, against the published figures

Published This run
13 pages, MB/s (Parsec / Lexbor / html5ever) 370 / 242 / 82 362 / 242 / 83
Selectors, ms (Parsec / Lexbor) 226 / 728 243 / 715
URLs, ns (Parsec / Lexbor / Ada) 107 / 243 / 142 102 / 238 / 102
CSS tokenize, MB/s (Parsec / Lexbor / cssparser) 389 / 210 / 318 358 / 219 / 327
CSS parse, MB/s 211 / 112 / 196 226 / 118 / 201
JS parse, MB/s (Parsec / oxc / swc) 380 / 363 / 147 373 / 358 / 156
JS lexer, MB/s 347 / 568 / 328 599 / 564 / 323
Real world, MB/s (Parsec / Lexbor) 933 / 523 over 1,731 pages 1,007 / 543 over 1,746
Final boss, s per 1,000 (Parsec / Lexbor / html5ever) 1.02 / 1.94 / 5.99 0.99 / 1.93 / 5.99

Two published claims don't hold in this run:

  • Parsec holds more memory than Lexbor on 4 of the 13 pages: BBC News, eBay, the New York Times and Reddit.
  • Ada is now level with Parsec on URLs.

The lexer's lead over oxc is new since #249 and #253.

Tests

  • cargo build --release, cargo fmt, and cargo clippy --release -- -D warnings in bench/ are clean, and scripts/check-headers.sh passes.
  • Every mode above wrote its file. The website loader, coming next, reads all six, checks the schema and builds every page from them. I've built it against these files locally.

…hand

The bench printed tables and nothing else, so the website kept 27
figures typed in from the docs, and a new run meant retyping them.

`--json PATH`, with any mode, now also writes every figure the run
prints, one object per figure (bench, source, bytes, parser, metric,
value), with the date, the commit, rustc, the machine, the load average
when the run ended and each parser's version (schema 1, in
src/results.rs). The tables it prints don't change.

bench/results/2026-11-29-m2-max/ holds a full run made with it: the
pages, selectors, URLs and CSS (pages.json), decoding, JavaScript, the
JavaScript lexer, the final boss and the real-world corpus.

Most of the real-world list's pages had changed since 21 November, so
fetch-realworld.sh would have kept only a few hundred of them.
realworld.tsv is a fresh fetch of Netweir's 2,709 URLs instead: 1,746
pages kept, 563.4 MB.

@foothillsdigital foothillsdigital left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving acedf4d. I recomputed the table from the committed JSON, and it holds. Two small things, neither blocking.

The files back the table. From bench/results/2026-11-29-m2-max/*.json, as bytes / value for each seconds figure:

  • pages.json, "all real pages": Parsec 362, Lexbor 242, html5ever 83 MB/s.
  • realworld.json, "1746 pages": Parsec 1,007, Lexbor 543 (html5ever 166) MB/s over 563.4 MB.
  • boss.json, seconds_per_1000_pages: 0.99, 1.93 and 5.99.
  • js.json, "all": Parsec 373, oxc 358, swc 156 MB/s.
  • The memory claim: of the 13 real pages' peak_bytes, Parsec is above Lexbor on exactly the four you name: bbc-news (2.7 vs 2.6 MB), ebay (3.8 vs 3.6), nytimes (10.8 vs 7.3) and reddit-programming (4.0 vs 3.0).
  • schema 1, commit 72d32f0, and a one-minute load of 2.56 in pages.json, inside the 1.8 to 3.2 you give.

1. One figure that moved isn't in the table. realworld.json has "pages Lexbor parses faster" = 8, and parsec.tools (realWorld.lexborFaster) and the docs' Real-world page both say 13 of 1,731. That's good news, but it's a third published claim this run changes, so it's worth listing beside the two you did, for whoever moves the site onto these files.

2. A failed gate writes no JSON. The file is written from Output's Drop at the end of main, and boss.rs:1349 ends a failing --smoke/--gate run with std::process::exit(1), which runs no destructors. (The exit(TIMED_OUT) at line 761 is in the child worker, which is fine.) So the one run whose figures you'd most want to inspect leaves none. Writing the figures before that exit, for example with a results::flush() the Drop also calls, or returning an exit code from main, would keep them. That's only if the gate is meant to be run with --json; if not, a line in results.rs saying so is enough.

The per-figure shape (bench, source, bytes, parser, metric, value), with the machine and the versions beside it, is easy to read from the site, and keeping html, html-generated and html-hostile apart is the right call.

@jamesconwaydev
jamesconwaydev added this pull request to the merge queue Nov 29, 2026
Merged via the queue into main with commit 32be291 Nov 29, 2026
44 checks passed
@jamesconwaydev
jamesconwaydev deleted the bench-json branch November 29, 2026 06:56
@jamesconwaydev

Copy link
Copy Markdown
Collaborator Author

Thanks for re-deriving the table. On your two points:

  1. Lexbor-faster is now 8 of 1,746, not 13 of 1,731. parsec.tools works that count out from realworld.json rather than quoting it, and the docs' Real-world page is rewritten from the same run, both in feat(site): benchmark figures were typed in by hand and could go stale website#4.
  2. The gate's exit(1): fixed in fix(bench): a failed boss gate wrote no --json figures #260. results::write() writes the figures once, Output's Drop calls it, and boss calls it just before the exit.

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.

2 participants