Closed
Bug 1474384
Opened 7 years ago
Closed 7 years ago
<xul:browser>.currentURI for lazy browsers is very eager to allocate nsIURI objects
Categories
(Firefox :: Tabbed Browser, enhancement, P3)
Firefox
Tabbed Browser
Tracking
()
Tracking | Status | |
---|---|---|
firefox63 | --- | fixed |
People
(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)
References
Details
(Whiteboard: [fxperf:p1])
Attachments
(1 file, 2 obsolete files)
See this profile please:
https://perfht.ml/2KLp2Dp
The culprit is this line: https://searchfox.org/mozilla-central/rev/28daa2806c89684b3dfa4f0b551db1d099dda7c2/browser/base/content/tabbrowser.js#1907
Here, every time browser.currentURI is called, we create a new nsIURI object! This is very inefficient, as this profile shows. The majority of the time spent here is doing this work, resulting in UI jank.
The browser session being profiled here contains a large session that has been restored and hence contains a lot of lazy browsers.
Updated•7 years ago
|
Whiteboard: [qf] → [qf][fxperf]
Assignee | ||
Comment 1•7 years ago
|
||
Attachment #8990784 -
Flags: review?(mconley)
Assignee | ||
Comment 2•7 years ago
|
||
Assignee | ||
Updated•7 years ago
|
Assignee: nobody → ehsan
Comment 3•7 years ago
|
||
Comment on attachment 8990784 [details] [diff] [review]
Memoize the nsIURI object returned from the currentURI getter for lazy <xul:browser> objects
>--- a/browser/base/content/tabbrowser.js
>+++ b/browser/base/content/tabbrowser.js
>@@ -1899,17 +1899,23 @@ window._gBrowser = {
> getter = () => aTab.hasAttribute("muted");
> break;
> case "contentTitle":
> getter = () => SessionStore.getLazyTabValue(aTab, "title");
> break;
> case "currentURI":
> getter = () => {
> let url = SessionStore.getLazyTabValue(aTab, "url");
>- return Services.io.newURI(url);
>+ // Avoid recreating the same nsIURI object over and over again...
>+ if ("_cachedURL" in browser &&
>+ browser._cachedURL &&
>+ browser._cachedURL.spec == url) {
>+ return browser._cachedURL;
The browser._cachedURL null-check makes the |"_cachedURL" in browser| check redundant.
What's the point of the string comparison?
As for the name, I'd prefer _cachedCurrentURI or so.
Please also delete this in _insertBrowser, e.g. after this line: https://searchfox.org/mozilla-central/rev/c579ce13ca7864c5df9711eda730ceb00501aed3/browser/base/content/tabbrowser.js#1990
Attachment #8990784 -
Flags: review?(mconley)
Assignee | ||
Comment 4•7 years ago
|
||
Attachment #8991086 -
Flags: review?(dao+bmo)
Assignee | ||
Updated•7 years ago
|
Attachment #8990784 -
Attachment is obsolete: true
Assignee | ||
Comment 5•7 years ago
|
||
Comment 6•7 years ago
|
||
Comment on attachment 8991086 [details] [diff] [review]
Memoize the nsIURI object returned from the currentURI getter for lazy <xul:browser> objects
>--- a/browser/base/content/tabbrowser.js
>+++ b/browser/base/content/tabbrowser.js
>@@ -1899,17 +1899,21 @@ window._gBrowser = {
> getter = () => aTab.hasAttribute("muted");
> break;
> case "contentTitle":
> getter = () => SessionStore.getLazyTabValue(aTab, "title");
> break;
> case "currentURI":
> getter = () => {
> let url = SessionStore.getLazyTabValue(aTab, "url");
>- return Services.io.newURI(url);
>+ // Avoid recreating the same nsIURI object over and over again...
>+ if (browser._cachedURL) {
>+ return browser._cachedURL;
>+ }
>+ return browser._cachedURL = Services.io.newURI(url);
_cachedCurrentURI please
r=me with that change or a compelling reason for preferring _cachedURL as the name
Attachment #8991086 -
Flags: review?(dao+bmo) → review+
Updated•7 years ago
|
Whiteboard: [qf][fxperf] → [qf:p1:f64][fxperf:p1]
Assignee | ||
Comment 7•7 years ago
|
||
Assignee | ||
Updated•7 years ago
|
Attachment #8991086 -
Attachment is obsolete: true
Assignee | ||
Updated•7 years ago
|
Keywords: checkin-needed
Pushed by apavel@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/4d3bd7a6b705
Memoize the nsIURI object returned from the currentURI getter for lazy <xul:browser> objects; r=dao
Keywords: checkin-needed
Comment 9•7 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 7 years ago
status-firefox63:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 63
Updated•3 years ago
|
Performance Impact: --- → P1
Whiteboard: [qf:p1:f64][fxperf:p1] → [fxperf:p1]
You need to log in
before you can comment on or make changes to this bug.
Description
•