Lots of StringBuffer allocations during TodoMVC subtests
Categories
(Core :: DOM: HTML Parser, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox147 | --- | fixed |
People
(Reporter: denispal, Assigned: denispal)
References
(Blocks 1 open bug)
Details
(Keywords: perf-alert)
Attachments
(3 external files)
While investigating the inner html parsing performance during Speedometer3, I noticed we seem to allocate a lot of strings during tokenization. A lot of these allocations are for strings such as checkbox (30,000 times!), 0, 1 which are already static atoms. This occurs mostly during all of the TodoMVC subtests. Below is the list of most frequently allocated strings during parsing.
This seems to be most noticeable on Windows and Android where a lot of the time is spent in malloc locks during allocation.
Here is a profile on Windows: https://share.firefox.dev/4nalkQV
30385 [StringBuffer::Create] UTF-16: "checkbox" (len=8, bytes=16)
11528 [StringBuffer::Create] UTF-16: "2" (len=1, bytes=2)
9984 [StringBuffer::Create] UTF-16: "Smock_TaskList_18_N_svg__fill" (len=29, bytes=58)
9322 [StringBuffer::Create] UTF-16: "18" (len=2, bytes=4)
7702 [StringBuffer::Create] UTF-16: "5" (len=1, bytes=2)
6770 [StringBuffer::Create] UTF-16: "4" (len=1, bytes=2)
6739 [StringBuffer::Create] UTF-16: "1" (len=1, bytes=2)
6548 [StringBuffer::Create] UTF-16: "3" (len=1, bytes=2)
6247 [StringBuffer::Create] UTF-16: "0" (len=1, bytes=2)
5212 [StringBuffer::Create] UTF-16: "9" (len=1, bytes=2)
5010 [StringBuffer::Create] UTF-16: "0.25" (len=4, bytes=8)
4628 [StringBuffer::Create] UTF-16: "http://www.w3.org/2000/svg" (len=26, bytes=52)
4338 [StringBuffer::Create] UTF-16: "just-span spectrum-TreeView-itemLabel" (len=37, bytes=74)
4338 [StringBuffer::Create] UTF-16: "spectrum-TreeView-itemLink" (len=26, bytes=52)
2779 [StringBuffer::Create] UTF-16: "10" (len=2, bytes=4)
2496 [StringBuffer::Create] UTF-16: "M4.775 7.958a.5.5 0 0 1-.34-.133l-1.038-.958a.5.5 0 1 1 .678-.735l.656.606 2.14-2.52a.5.5 0 1 1 .762.65L5.156 7.785a.5.5 0 0 1-.35.175ZM4.775 12.959a.5.5 0 0 1-.34-.133l-1.038-.959a.5.5 0 0 1 .678-.735l.656.606 2.14-2.52a.5.5 0 1 1 .762.65l-2.477 2.916a.5.5 0 0 1-.35.176Z" (len=272, bytes=544)
2496 [StringBuffer::Create] UTF-16: "task-list-icon spectrum-Icon spectrum-TreeView-itemIndicator spectrum-TreeView-itemIcon spectrum-Icon--sizeM" (len=108, bytes=216)
2496 [StringBuffer::Create] UTF-16: "spectrum-TreeView-item nodetype-nonExpandableItem" (len=49, bytes=98)
2496 [StringBuffer::Create] UTF-16: "M1 1.5v14a.5.5 0 0 0 .5.5h15a.5.5 0 0 0 .5-.5v-14a.5.5 0 0 0-.5-.5h-15a.5.5 0 0 0-.5.5ZM16 15H2V2h14Z" (len=101, bytes=202)
2052 [StringBuffer::Create] UTF-16: "fill:#464646" (len=12, bytes=24)
1848 [StringBuffer::Create] UTF-16: "M12 9a.994.994 0 0 1-.292.705l-3.992 3.99a1 1 0 1 1-1.436-1.387l.025-.024L9.591 9 6.305 5.715A1 1 0 0 1 7.69 4.28l.025.025 3.991 3.99A.994.994 0 0 1 12 9Z" (len=154, bytes=308)
1848 [StringBuffer::Create] UTF-16: "spectrum-TreeView spectrum-TreeView--sizeS" (len=42, bytes=84)
1842 [StringBuffer::Create] UTF-16: "spectrum-Icon spectrum-TreeView-itemIndicator spectrum-TreeView-itemIcon" (len=72, bytes=144)
1644 [StringBuffer::Create] UTF-16: "spectrum-TreeView-item is-open nodetype-expandableItem" (len=54, bytes=108)
1326 [StringBuffer::Create] UTF-16: "30.577933450087567" (len=18, bytes=36)
| Assignee | ||
Comment 1•1 year ago
|
||
I wrote a patch to atomize type attributes, and the strings "0" - "9". It seems to give around a 1% improvement on Windows and Android. This reduces the number of StringBuffer allocations from 1125294 to 503984 which is about a 55% reduction.
Comment 2•1 year ago
|
||
NI :hsivonen to take a look at this.
| Assignee | ||
Comment 3•1 year ago
|
||
Add static atoms for "2" -> "9", and do a fast path check for any single digit strings during tokenization and return the static atom directly. Also atomize type attributes during tokenization. This patch also cleans up some code in Element::SetAttr and nsHtml5TreeOperation so that it's easier to pass through an atom.
Updated•1 year ago
|
Comment 4•1 year ago
|
||
Clearing needinfo to handle this via review.
(It's somewhat unfortunate that we need to have optimizations like this for synthetic tests that repeat the same thing more than in a real-world case. The existing special handling for class values was added for an earlier Speedometer.)
Comment 6•1 year ago
|
||
| bugherder | ||
backed out for causing Bug 1997489: https://hg.mozilla.org/integration/autoland/rev/42c0e7efe0f28e959f628fae2e01bf054227bbdd
Comment 9•1 year ago
|
||
Backout merged to central: https://hg-edge.mozilla.org/mozilla-central/rev/42c0e7efe0f2
| Assignee | ||
Comment 10•1 year ago
|
||
| Assignee | ||
Comment 11•1 year ago
|
||
Comment 12•1 year ago
|
||
Comment 13•1 year ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/a0a4d1aa8331
https://hg.mozilla.org/mozilla-central/rev/0b7da8e951eb
https://hg.mozilla.org/mozilla-central/rev/a55e6a8352a8
Comment 14•1 year ago
|
||
Comment 15•1 year ago
|
||
(In reply to Sandor Molnar[:smolnar] from comment #13)
https://hg.mozilla.org/mozilla-central/rev/a0a4d1aa8331
https://hg.mozilla.org/mozilla-central/rev/0b7da8e951eb
https://hg.mozilla.org/mozilla-central/rev/a55e6a8352a8
Perfherder has detected a browsertime performance change from push a55e6a8352a8395f09179cf38ab75a7ad69e1d25.
If you have any questions, please reach out to a performance sheriff. Alternatively, you can find help on Slack by joining #perf-help, and on Matrix you can find help by joining #perftest.
Improvements:
| Ratio | Test | Platform | Options | Absolute values (old vs new) | Performance Profiles |
|---|---|---|---|---|---|
| 2% | speedometer3 TodoMVC-JavaScript-ES6-Webpack-Complex-DOM/Adding100Items/Sync | macosx1500-aarch64-shippable | fission webrender | 11.10 -> 10.87 | Before/After |
| 2% | speedometer3 TodoMVC-JavaScript-ES6-Webpack-Complex-DOM/Adding100Items/total | macosx1500-aarch64-shippable | fission webrender | 12.91 -> 12.65 | Before/After |
Details of the alert can be found in the alert summary, including links to graphs and comparisons for each of the affected tests.
If you need the profiling jobs you can trigger them yourself from treeherder job view or ask a performance sheriff to do that for you.
You can run all of these tests on try with ./mach try perf --alert 47488
The following documentation link provides more information about this command.
| Assignee | ||
Updated•1 year ago
|
Updated•11 months ago
|
Description
•