Skip to content

perf: fused text-only element serialization — 1.15 GB/s (TODO 194d) - #404

Merged
ronaldtse merged 1 commit into
mainfrom
perf/serialize-text-elem
Aug 17, 2026
Merged

perf: fused text-only element serialization — 1.15 GB/s (TODO 194d)#404
ronaldtse merged 1 commit into
mainfrom
perf/serialize-text-elem

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Summary

TODO 194d — the compact-mode text-only element (<p>text</p>, the
dominant shape in text-heavy documents) emitted through five
buffer calls plus a node-dispatch hop. A pure inline escaper —
preserving the entity-reference semantics of the run-batched
walkers (refs emit as-is, bare & escapes, quotes ordinary in text
mode) — now emits the whole open tag + escaped text + close tag
from ONE worst-case reservation.

Measurement

1.6 MB text-heavy document: 1.06 -> 1.15 GB/s (+8%; cumulative
0.40 -> 1.15 across 194b/c/d). pugixml: 1.54 GB/s — gap now
1.34x, with the remaining cost identified as the per-element
recursion and the is-text-only detection walk.

Validation

558/558 tests including serialize round-trips, ASAN clean, zero
leaks. (The perf suite's indexed-walk spec flaked twice under
local load spikes of 200-466; stable 3/3 in isolation and green
on every CI run today — no change made.)

A compact-mode text-only element (<p>text</p> — the dominant
shape in text-heavy documents) emitted through five buffer calls
plus a node-dispatch hop. A pure inline escaper (preserving the
entity-reference semantics of the run-batched walkers) now emits
the whole open tag + escaped text + close tag from ONE worst-case
reservation.

Measured on the 1.6 MB text-heavy document: 1.06 -> 1.15 GB/s
(cumulative 0.40 -> 1.15 across 194b/c/d; pugixml 1.54 — gap now
1.34x, remaining cost is the per-element recursion and
is-text-only detection walk). 558 tests, ASAN, zero leaks.
@ronaldtse
ronaldtse merged commit af35e8b into main Aug 17, 2026
18 checks passed
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