perf: fused text-only element serialization — 1.15 GB/s (TODO 194d) - #404
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TODO 194d — the compact-mode text-only element (
<p>text</p>, thedominant 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.)