Closed Bug 1369751 Opened 7 years ago Closed 7 years ago

Initializing browser-sidebar.js is visible in startup profiles before first paint

Categories

(Firefox :: General, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
Firefox 55
Iteration:
55.7 - Jun 12
Tracking Status
firefox55 --- fixed

People

(Reporter: florian, Assigned: florian)

References

(Blocks 1 open bug)

Details

(Whiteboard: [photon-performance])

Attachments

(1 file)

See https://perfht.ml/2s1skYS from a startup profile on a very slow netbook. Most of the browser-sidebar.js time is spent in the <browser> and <label> constructors. They are triggered by the getElementById calls from init(). We shouldn't need to construct the sidebar browser before first paint, especially if the sidebar is going to be hidden.
Attached patch PatchSplinter Review
Attachment #8873865 - Flags: review?(mdeboer)
Comment on attachment 8873865 [details] [diff] [review] Patch Review of attachment 8873865 [details] [diff] [review]: ----------------------------------------------------------------- r=me with comments addressed. Thanks! ::: browser/base/content/browser-sidebar.js @@ +27,5 @@ > > _box: null, > + // The constructor of this label accesses the browser element due to the > + // control="sidebar" attribute, so avoid getting this label during startup. > + get _title() { return document.getElementById("sidebar-title"); }, Please cache the element: ```js if (this.__title) return this.__title; return this.__title = document.getElementById("sidebar-title"); ``` And the same for the `browser` getter above. This can potentially be repeated for all the elements that are fetched in the init() method, right? Perhaps we can do something smarter? Can be done at a later date, but worth a thought just in case.
Attachment #8873865 - Flags: review?(mdeboer) → review+
Status: NEW → ASSIGNED
Iteration: --- → 55.7 - Jun 12
Flags: qe-verify?
Priority: -- → P1
Whiteboard: [photon-performance]
Pushed by florian@queze.net: https://hg.mozilla.org/integration/mozilla-inbound/rev/d1bdd265b00d avoid constructing the sidebar browser before first paint, r=mikedeboer.
(In reply to Mike de Boer [:mikedeboer] from comment #2) I cached _title and browser as requested. But note that only the first getElementById call is expensive, because it forces attachment of the XBL binding. > This can potentially be > repeated for all the elements that are fetched in the init() method, right? > Perhaps we can do something smarter? I'm actually not sure we need to store references to these elements, I think we could do a getElementById call each time we need them.
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 55
Flags: qe-verify? → qe-verify-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: