Skip to content

perf(web): decode HTML tokenizer scan loop to bytes once - #896

Merged
ormastes merged 1 commit into
mainfrom
work/web-perf-round7b-html-parse-2026-09-13
Sep 13, 2026
Merged

ormastes merged 1 commit into
mainfrom
work/web-perf-round7b-html-parse-2026-09-13

Conversation

@ormastes

Copy link
Copy Markdown
Owner

Summary

  • pp_html_us (HTML tokenize+tree build) was round 6's largest parse-phase bucket; its own .bytes()-based attempt regressed because it redecoded the whole remaining document on every _find_char/_find_substr call.
  • This decodes html.bytes() once per document at the top of html_tokenizer_tokenize_with_limits and threads that single [u8] array through the hot scan loop (_find_byte, _scan_char_data_b, _find_tag_close_b, _is_alpha_byte) instead of allocating a text slice or redecoding per character/call.
  • Doc: doc/10_metrics/ui/web_perf_round7b_2026-09-13.md.

Test plan

  • A/B x4 alternating pairs on test/05_perf/ui/web/pipeline_bench.spl: pp_html_us -5.5%/-4.6%/+0.6%/-10.2%, Draw-IR digest byte-identical all 8 pairs both sides
  • test/01_unit/browser_engine/html_tokenizer_abrupt_comment_spec.spl 4/4 pass, identical both sides
  • test/unit/browser_engine/html_tokenizer_spec.spl 17/17 pass, identical both sides
  • test/01_unit/browser_engine/html_tokenizer_spec.spl 23/53-passing baseline confirmed pre-existing and byte-identical failure set before/after
  • GPU boundary audit PASS
  • check-no-conflict-markers-push, check-tree-size-push, check-test-tree-divergence-delta all PASS, 0 new divergence

🤖 Generated with Claude Code

https://claude.ai/code/session_01TVraTPgGDVypESTsVqXPgi

… call

pp_html_us (HTML tokenize+tree build) was the largest parse-phase bucket per
round 6 (doc/10_metrics/ui/web_perf_round6_2026-09-13.md), whose own
.bytes()-based attempt regressed because it redecoded the whole remaining
document on every _find_char/_find_substr call. This threads a single
text_to_bytes(html) decode through the whole outer scan loop instead:
_find_byte/_scan_char_data_b/_find_tag_close_b/_is_alpha_byte index that one
pre-decoded [u8] array per probe rather than allocating a length-1 text via
html.slice(pos, pos+1) or re-decoding bytes per call.

A/B (8-page catalog, 4 alternating pairs): pp_html_us -5.5%/-4.6%/+0.6%/-10.2%,
Draw-IR digest byte-identical all 8 pairs both sides. html_tokenizer specs
unchanged (abrupt_comment 4/4, unit mirror 17/17; the 23/53-passing spec's
30-example failure set is confirmed pre-existing and byte-identical before
vs after). GPU boundary audit PASS.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TVraTPgGDVypESTsVqXPgi
@ormastes
ormastes merged commit ede84ad into main Sep 13, 2026
1 of 35 checks passed
@ormastes
ormastes deleted the work/web-perf-round7b-html-parse-2026-09-13 branch September 13, 2026 11:32

This branch was successfully deployed

No deployments
self-review-admission — 173fe80f Deployed Sep 13, 2026 by ormastes via Invalidate changed PR self-review state #4979
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.

1 participant