Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3ce7856bc424d5194a4fb8325b57d8e1a7cb2fed
https://github.com/WebKit/WebKit/commit/3ce7856bc424d5194a4fb8325b57d8e1a7cb2fed
Author: Nipun Shukla <[email protected]>
Date: 2026-03-05 (Thu, 05 Mar 2026)
Changed paths:
A PerformanceTests/Parser/pending-text-buffer-parser.html
M Source/WebCore/dom/CharacterData.cpp
M Source/WebCore/dom/CharacterData.h
M Source/WebCore/html/parser/HTMLConstructionSite.cpp
M Source/WebCore/html/parser/HTMLConstructionSite.h
M Source/WebCore/xml/parser/XMLDocumentParser.cpp
Log Message:
-----------
WebKit is slow at opening very big HTML files
https://bugs.webkit.org/show_bug.cgi?id=308852
rdar://144245503
Reviewed by Ryosuke Niwa.
CharacterData::parserAppendData() previously called makeString() on
every chunk the HTML parser received, which copies all previously
accumulated text on each receipt, making total work occur in
polynomial time O(n^2) for large text nodes.
This change makes parserAppendData() take a StringBuilder&, which lives
in HTMLConstructionSite that is lazily heap allocated before the first
parserAppendData() call, avoiding polynomial time complexity via
StringBuilder's exponential growth. This StringBuilder is only
created when text nodes are split across multiple chunks.
The included microbenchmark is progressed from ~240 ms/run to ~110 ms/run.
This patch does not cause any behavior change.
* PerformanceTests/Parser/pending-text-buffer-parser.html: Added.
* Source/WebCore/dom/CharacterData.cpp:
(WebCore::CharacterData::parserAppendData):
* Source/WebCore/dom/CharacterData.h:
* Source/WebCore/html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::finishedParsing):
(WebCore::HTMLConstructionSite::insertTextNode):
* Source/WebCore/html/parser/HTMLConstructionSite.h:
* Source/WebCore/xml/parser/XMLDocumentParser.cpp:
(WebCore::XMLDocumentParser::updateLeafTextNode):
Canonical link: https://commits.webkit.org/308781@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications