Skip to content

feat(site): benchmark figures were typed in by hand and could go stale - #4

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

jamesconwaydev merged 1 commit into
mainfrom
bench-results

Conversation

@jamesconwaydev

Copy link
Copy Markdown
Contributor

Problem

apps/site/src/data/benchmarks.ts held 27 figures typed in from the docs under two shortcut: comments. The pages also made claims nothing checked against them: "ahead on all thirteen", "less memory on every page", "Lexbor was faster on 13", "All three agree on every one". Since parsec-html/parsec#259, Parsec's bench writes its figures as JSON, and a full run of 29 November 2026 is committed under bench/results/.

Change

  • benchmarks.ts is now a loader. At build time it lists bench/results/ on Parsec's main through the GitHub API, takes the newest directory, and reads each mode's file. A file whose schema isn't 1, a figure that isn't {bench, source, bytes, parser, metric, value}, or a figure a page needs that the run lacks fails the build. The hand-copied constants and both shortcut: comments are gone.

  • Claims are worked out from the figures:

    • who's ahead on how many pages, selectors and hostile inputs, and where Parsec holds more memory than Lexbor;
    • which pages have a smaller html5ever tree, and which JavaScript sources oxc wins;
    • whether the URL parsers disagree, and whether anything crashed in the real-world run and the final boss;
    • whether Lexbor's own decoders win on dense GBK.

    A run where a claim stops holding changes the sentence, not just the number. Page counts, stylesheet counts, versions, machine and dates come from the run too.

  • Pages that read it: /benchmarks/, /parsec-vs-lexbor/, the homepage, /netweir/ and /benchmarks/methodology/, which also explains --json and links bench/results.

  • PARSEC_BENCH_RESULTS=/path/to/run builds against a local run before it's on main.

  • Docs:

    • Real-world benchmarks: moves to the new run over the fresh 1,746-page list. The tables are the bench's output, and the lead, corpus counts, "Where Parsec loses" and the rest are rewritten from it.
    • Benchmarks: the lead and note now describe the 29 November run and say the sections below keep their own dated runs. "Running it" says how to make and publish a run with --json.

What changes on the pages

  • Speed:
    • 13 pages: 362, 242 and 83 MB/s (was 370, 242 and 82).
    • Real world: 1,007 against 543 over 1,746 pages (was 933 against 523 over 1,731), with Lexbor faster on 8 pages (was 13).
    • JavaScript: 373 against oxc's 358 (was 380 against 363). The lexer now leads oxc, 599 against 564.
  • Claims that changed with the data:
    • Parsec holds more memory than Lexbor on 4 of the 13 pages.
    • html5ever's tree is smaller on 9.
    • Ada is level with Parsec on URLs, 102 ns each.
    • Parsec is ahead on 31 of 32 selectors.
    • oxc wins 10 of the 14 JavaScript sources.

Tests

  • pnpm build and pnpm check on both apps, against Parsec's main: 0 errors.
  • scripts/check-links.mjs is clean on both dists.
  • I read each rendered sentence against the JSON.

apps/site/src/data/benchmarks.ts held 27 figures copied from the docs,
and sentences like "ahead on all thirteen" or "less memory on every
page" that nothing checked against them.

The figures now come from the newest run in Parsec's bench/results/,
written by the bench's --json and read when the site is built. A file
with the wrong schema, or a figure a page needs and the run lacks,
fails the build. Every claim about who wins is worked out from the
same figures, so a run where it no longer holds changes the sentence.
PARSEC_BENCH_RESULTS points the build at a local run instead.

The Benchmarks and Real-world benchmarks docs pages move to the same
run, 29 November 2026: the real-world tables are the new run's output,
over the fresh 1,746-page list, and the Benchmarks page's summary and
note say which run the site quotes and how to make one.

@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 875e65a, with one cosmetic nit.

  • Build: pnpm --filter site build reads bench/results/2026-11-29-m2-max/ from Parsec's main and builds 19 pages. astro check shows 0 errors and 0 warnings.
  • The rendered pages match the JSON. Among them: 362 vs 242 and 83 MB/s; 1,746 pages at 1,007 vs 543 MB/s; "Lexbor was faster on 8 of them"; "with less memory on 9 of them", which is 13 minus the four where Parsec is higher; 243 vs 715 ms for selectors; 373 vs 358 and 156 MB/s for JavaScript; oxc still ahead on the smallest inline scripts; and neither parser crashing on the real-world run.
  • No old figure is left. grep over dist for 370 MB, 933, 1,731 and 13 of 1 finds nothing.
  • It fails closed, as the description says:
    • with PARSEC_BENCH_RESULTS pointed at a copy of the run that lacks the "all real pages" figures, the build stops with bench/results pages.json has no html / all real pages / Parsec / seconds;
    • with a file's schema set to 2, it stops with realworld.json: schema 2, this site reads 1.

Nit: the figures from the loader print without a thousands separator, so /parsec-vs-lexbor/ says "1,746 production pages … 1007 MB/s against 543", and /netweir/ says "Parsec at 1007 MB/s", next to counts that do have one. The README (#261) writes "1,007". Running the loader's numbers through the same toLocaleString('en-US') the page counts use would make them match.

Working the sentences out from the figures, so a run where a claim stops holding changes the wording, is the part that'll keep paying off.

@jamesconwaydev
jamesconwaydev merged commit 41ee055 into main Nov 29, 2026
1 check passed
@jamesconwaydev
jamesconwaydev deleted the bench-results branch November 29, 2026 07:04
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