Use AutoTArray in ChildCommandDispatcher to avoid reallocation overhead
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox111 | --- | fixed |
People
(Reporter: dholbert, Assigned: dholbert)
References
(Blocks 1 open bug)
Details
(Whiteboard: [sp3])
Attachments
(1 file)
ChildCommandDispatcher two local nsTArray variables:
https://searchfox.org/mozilla-central/rev/ef5dad8c11a556acd68ca3b9dcd77b226e0aaa29/dom/base/nsGlobalWindowOuter.cpp#6394,6404-6406
class ChildCommandDispatcher : public Runnable {
...
NS_IMETHOD Run() override {
nsTArray<nsCString> enabledCommands, disabledCommands;
mRoot->GetEnabledDisabledCommands(enabledCommands, disabledCommands);
In a local speedometer run, I got two samples where we were calling AppendElement
on one of those arrays:
https://share.firefox.dev/3XEzrCj
I did a local run to print out the sizes of these arrays, to see what the space-of-common-values is like, on my linux system at least. During a Speedoometer 3 run, enabledCommands
topped out at 62, while disabledCommands
topped out at 70.
So, let's just use AutoTArray
with capacity 70
for both of these, to avoid reallocation churn. (Even if we occasionally overshoot 70 by a bit, we'll probably only have to dynamically allocate once, instead of several times.)
Assignee | ||
Comment 1•2 years ago
|
||
This patch doesn't change user-visible behavior.
The AutoTArray size that I'm using, 70, comes from the maximum values that I
observed for these arrays, during a local run of Speedometer 3 on Linux. The
largest 'disabledCommands' array that I encountered had length 70 (and this was
the most common length that this array had); while the largest
'enabledCommands' array was only a bit smaller, with a length of 62.
Updated•2 years ago
|
Comment 3•2 years ago
|
||
bugherder |
Updated•2 years ago
|
Updated•2 years ago
|
Description
•