Closed
Bug 1488697
Opened 6 years ago
Closed 6 years ago
StringBuilder::ToString should use BulkWrite
Categories
(Core :: DOM: Core & HTML, enhancement, P3)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla64
Tracking | Status | |
---|---|---|
firefox64 | --- | fixed |
People
(Reporter: hsivonen, Assigned: hsivonen)
References
(Blocks 1 open bug)
Details
(Keywords: perf)
Attachments
(1 file)
StringBuider ensures that the appends it does can't fail. It also knows that what it what it appends can't alias the buffer of the string. Yet, on each append (including on a per-code unit basis!), the string implementation re-checks for these conditions. Also, the zero terminator gets written and rewritten all the time. Additionally, StringBuider forgoes SIMD acceleration when appending text nodes that contain markup-significant characters. This can be made more efficient using BulkWrite.
Assignee | ||
Comment 1•6 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=b38e73af08187a45386372866619814d66bcf6f8
Assignee | ||
Comment 2•6 years ago
|
||
smaug, can you recommend a benchmark that tests the innerHTML getter?
Flags: needinfo?(bugs)
Assignee | ||
Comment 3•6 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=c6a4070fdb7a770ac3eef95b40be9c1a2d90cc62
Comment 4•6 years ago
|
||
Look at the blame of StringBuilder. It was added because of performance.
Flags: needinfo?(bugs)
Comment 5•6 years ago
|
||
https://bugzilla.mozilla.org/show_bug.cgi?id=744830#c10 has a link to at least some testcase.
Updated•6 years ago
|
Priority: -- → P3
Assignee | ||
Comment 6•6 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=bfe5039fc70c4cd69a9a3d9be14852422d60b327
Assignee | ||
Comment 7•6 years ago
|
||
Opt builds: https://treeherder.mozilla.org/#/jobs?repo=try&revision=99471e33c9e6fa97e63e9eabfb947d411ad91b09
Assignee | ||
Comment 8•6 years ago
|
||
Opt builds, now with more Windows wchar_t* trickery: https://treeherder.mozilla.org/#/jobs?repo=try&revision=d2be95e25ac4c31cafd848eef6188144757494a1
Assignee | ||
Comment 9•6 years ago
|
||
Opt builds, which #include for the Windows sadness: https://treeherder.mozilla.org/#/jobs?repo=try&revision=1c7f2673b8c8dd01c8bd3910295102d089b5abf1
Assignee | ||
Comment 10•6 years ago
|
||
Opt builds, still trying to get Windows to behave: https://treeherder.mozilla.org/#/jobs?repo=try&revision=2e539b2ebc7a6ec6b312b47f0ec6e048f53eadb6
Assignee | ||
Comment 11•6 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #5) > https://bugzilla.mozilla.org/show_bug.cgi?id=744830#c10 has a link to at > least some testcase. Thanks. With this patch, I see a 13% execution time reduction for body.innerHTML on that benchmark. Seems like a worthwhile improvement. (Desktop-class Haswell i7, from 182.8 ms to 158.2 ms.)
Assignee | ||
Comment 12•6 years ago
|
||
* Avoid the string implementation's capacity checks, since we know they succeed. * Avoid the string implementation's aliasing checks, since we know there's no aliasing. * Avoid writing the zero terminator more than once or out of sequence. * Use u"" literals when appending literals to a UTF-16 string. * Write runs of non-escaped code units instead of writing code unit by code unit in order to benefit from SIMD (either via memcpy or ConvertLatin1toUTF16). This results in a 13% execution time reduction on desktop Haswell i7 when getting the innerHTML of the body of the Selectors spec. (The WebKit optimization target from https://bugs.webkit.org/show_bug.cgi?id=81214 .) MozReview-Commit-ID: LAg3gkGJnpQ
Comment 13•6 years ago
|
||
Comment on attachment 9007148 [details] Bug 1488697 - Make StringBuilder::ToString avoid repeated capacity and aliasing checks as well as terminator writes. Olli Pettay [:smaug] has approved the revision.
Attachment #9007148 -
Flags: review+
Comment 14•6 years ago
|
||
Pushed by hsivonen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f00e66757346 Make StringBuilder::ToString avoid repeated capacity and aliasing checks as well as terminator writes. r=smaug
Comment 15•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/f00e66757346
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
status-firefox64:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Comment 16•6 years ago
|
||
Consider adding the `perf` keyword here?
Assignee | ||
Comment 17•6 years ago
|
||
On Haswell desktop i7 on Windows, for the body.innerHTML case, this patch took Firefox from slightly slower than Chrome to slightly faster than Chrome. On a Core2 Duo Mac, Safari is still faster in the body.innerHTML case. For the div cases, both WebKit and Blink are suspiciously slow compared to Gecko making me wonder if the div cases test a totally different thing in Gecko compared to WebKit/Blink.
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•