Add a benchmark for serialization and deserialization#739
Merged
Conversation
125dee4 to
7365152
Compare
simonwuelker
approved these changes
May 17, 2026
| fn deserialize_to_rcdom(stream: &[u8]) -> RcDom { | ||
| let opts = ParseOpts { | ||
| tree_builder: TreeBuilderOpts { | ||
| drop_doctype: true, |
Member
Author
There was a problem hiding this comment.
This was a copy and paste error from another one of the benchmarks. I'll remove this.
This is the first step toward improvements to HTML parsing and serialization performance. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
7365152 to
c72831b
Compare
mrobinson
added a commit
that referenced
this pull request
May 17, 2026
This change greatly improves the performance of serialization (up to 95% on some benchmarks) by changing the way that escaping of HTML entities works. It uses memchar to avoid creating a `chars()` iterator on the output stream. When run with the benchmark from #739, I see these results: ``` serialize "lipsum.html" time: [6.4817 µs 6.5021 µs 6.5212 µs] change: [−95.179% −95.013% −94.846%] (p = 0.00 < 0.05) Performance has improved. Found 5 outliers among 100 measurements (5.00%) 4 (4.00%) low severe 1 (1.00%) low mild serialize "lipsum-zh.html" time: [2.0815 µs 2.0888 µs 2.0947 µs] change: [−91.533% −90.940% −90.407%] (p = 0.00 < 0.05) Performance has improved. Found 15 outliers among 100 measurements (15.00%) 15 (15.00%) low severe serialize "medium-fragment.html" time: [7.7625 µs 7.7927 µs 7.8147 µs] change: [−84.424% −83.952% −83.486%] (p = 0.00 < 0.05) Performance has improved. serialize "small-fragment.html" time: [879.01 ns 886.43 ns 892.78 ns] change: [−89.813% −89.711% −89.610%] (p = 0.00 < 0.05) Performance has improved. serialize "tiny-fragment.html" time: [332.13 ns 332.78 ns 333.60 ns] change: [−27.768% −27.617% −27.457%] (p = 0.00 < 0.05) Performance has improved. Found 7 outliers among 100 measurements (7.00%) 3 (3.00%) low mild 3 (3.00%) high mild 1 (1.00%) high severe serialize "strong.html" time: [5.4946 µs 5.4988 µs 5.5030 µs] change: [−0.3133% −0.0322% +0.2349%] (p = 0.83 > 0.05) No change in performance detected. Found 7 outliers among 100 measurements (7.00%) 3 (3.00%) low severe 1 (1.00%) low mild 2 (2.00%) high mild 1 (1.00%) high severe ``` In this case `lipsum.html` deserialization time dropped from 122.81 µs to 6.5021 µs. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
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.
This is the first step toward improvements to HTML parsing and
serialization performance.