Closed Bug 1367029 Opened 8 years ago Closed 8 years ago

Telemetry takes 93ms in isDefaultBrowser on startup on reference hardware

Categories

(Toolkit :: Telemetry, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
mozilla56
Performance Impact high
Tracking Status
firefox56 --- fixed

People

(Reporter: gfritzsche, Assigned: Dexter)

References

Details

Attachments

(1 file)

Per Florian on IRC: > here is a cold startup profile on the quantum reference hardware: > https://perf-html.io/public/37eba6ac7b53f5d9ba25ba2a7e5755c72c2ea089/calltree/?implementation=js&range=0.0000_14.9170~0.0000_6.8354&search=Telemetry&thread=0 > Telemetry takes ~180ms before first paint > with most of the time spent in isDefaultBrowser and getGfxField
Depends on: 1358927
Priority: -- → P3
Summary: Telemetry takes 180ms in startup → Telemetry takes 180ms in startup, mostly in isDefaultBrowser and getGfxField
We already have bug 1358927 on the slow gfx init, so lets make this one about spending ~90ms in isDefaultBrowser. We have different code paths for this depending on the platform: Mac: https://dxr.mozilla.org/mozilla-central/rev/34ac1a5d6576d6775491c8a882710a1520551da6/browser/components/shell/nsMacShellService.cpp#38 Windows: https://dxr.mozilla.org/mozilla-central/rev/34ac1a5d6576d6775491c8a882710a1520551da6/browser/components/shell/nsWindowsShellService.cpp#290 In the raw profile data i see this is on Windows: > "platform":"Windows","oscpu":"Windows NT 10.0; WOW64" The Windows implementation doesn't do much, presumably this is slow from hitting: > ... CoCreateInstance(CLSID_ApplicationAssociationRegistration, > ... We should probably just delay this 1) until after first paint or 2) until the delayed telemetry init 60sec after startup.
No longer depends on: 1358927
Summary: Telemetry takes 180ms in startup, mostly in isDefaultBrowser and getGfxField → Telemetry takes 93ms in isDefaultBrowser on startup
Whiteboard: [qf]
Summary: Telemetry takes 93ms in isDefaultBrowser on startup → Telemetry takes 93ms in isDefaultBrowser on startup on reference hardware
Apparently we already hit isDefaultBrowser from "sessionstore-windows-restored" elsewhere: https://dxr.mozilla.org/mozilla-central/rev/34ac1a5d6576d6775491c8a882710a1520551da6/browser/components/nsBrowserGlue.js#1132
Whiteboard: [qf] → [qf:p1]
Priority: P3 → P2
Priority: P2 → P1
Assignee: nobody → alessio.placitelli
Comment on attachment 8877523 [details] Bug 1367029 - Defer gathering isDefaultBrowser until session restore completes. https://reviewboard.mozilla.org/r/148976/#review153844 ::: toolkit/components/telemetry/TelemetryEnvironment.jsm:785 (Diff revision 1) > + // To guard against slowing down startup, defer gatherings heavy environment > + // entries after the session is restored. Nit: I think that should be: "... defer gathering ... until the session is restored." ::: toolkit/components/telemetry/TelemetryEnvironment.jsm:1255 (Diff revision 1) > return null; > } > }, > > + _updateDefaultBrowser() { > + if (AppConstants.platform === "android" || !this._sessionWasRestored) { Do we need a special flag to track this? I don't that scales well. Can we just: - not call this in the initial `EnvironmentCache` init - update it once from the session restored topic ::: toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js:1572 (Diff revision 1) > + // Please note that this test must live after the default search engine one, > + // otherwise the other test will fail. Or we make it possible to do proper test resets for the environment data. Then we can presumably avoid these test depedencies. Lets file a follow-up on this?
Attachment #8877523 - Flags: review?(gfritzsche)
Comment on attachment 8877523 [details] Bug 1367029 - Defer gathering isDefaultBrowser until session restore completes. https://reviewboard.mozilla.org/r/148976/#review153844 > Do we need a special flag to track this? > I don't that scales well. > > Can we just: > - not call this in the initial `EnvironmentCache` init > - update it once from the session restored topic Good point. I was afraid pref flips & other stuff could happen right after cache init but before the session-restore, but that seems unlikely and didn't really happen in a few manual QA runs. > Or we make it possible to do proper test resets for the environment data. > Then we can presumably avoid these test depedencies. > > Lets file a follow-up on this? Hah! You know, while I was filing this bug I found that we already had that :-D I've changed the test accordingly.
Comment on attachment 8877523 [details] Bug 1367029 - Defer gathering isDefaultBrowser until session restore completes. https://reviewboard.mozilla.org/r/148976/#review153874 ::: toolkit/components/telemetry/TelemetryEnvironment.jsm:1264 (Diff revision 2) > + }, > + > /** > * Update the cached settings data. > */ > - _updateSettings() { > + _updateSettings(initialCall=false) { This can also be called from `_onPrefChanged()`, which could happen earlier. I'm not sure about scenarios where addons or the distribution code might flip prefs here. Could we just simplify this to call `_updateDefaultBrowser()` once per session? It doesn't look like we systematically update this currently whenever it changes anyway.
Attachment #8877523 - Flags: review?(gfritzsche)
Comment on attachment 8877523 [details] Bug 1367029 - Defer gathering isDefaultBrowser until session restore completes. https://reviewboard.mozilla.org/r/148976/#review153874 > This can also be called from `_onPrefChanged()`, which could happen earlier. > I'm not sure about scenarios where addons or the distribution code might flip prefs here. > > Could we just simplify this to call `_updateDefaultBrowser()` once per session? > It doesn't look like we systematically update this currently whenever it changes anyway. Good point, I've changed this to only be called once after the session is restored.
Comment on attachment 8877523 [details] Bug 1367029 - Defer gathering isDefaultBrowser until session restore completes. https://reviewboard.mozilla.org/r/148976/#review153892 ::: commit-message-a8f8e:1 (Diff revision 3) > +Bug 1367029 - Defer gathering isDefaultBrowser after session restore completes. r?gfritzsche Nit: "until session restore completes" ::: toolkit/components/telemetry/docs/data/environment.rst:39 (Diff revision 3) > hotfixVersion: <string>, // e.g. "20141211.01" > }, > settings: { > addonCompatibilityCheckEnabled: <bool>, // Whether application compatibility is respected for add-ons > blocklistEnabled: <bool>, // true on failure > - isDefaultBrowser: <bool>, // null on failure, not available on Android > + isDefaultBrowser: <bool>, // null on failure, not available on Android and before session restore completes Lets make this `null` instead of not available to avoid downstream changes. Can we call the possible data change (only updated once per session from Firefox 56 on) out below in the detailed docs?
Attachment #8877523 - Flags: review?(gfritzsche)
Comment on attachment 8877523 [details] Bug 1367029 - Defer gathering isDefaultBrowser until session restore completes. https://reviewboard.mozilla.org/r/148976/#review153892 > Lets make this `null` instead of not available to avoid downstream changes. > > Can we call the possible data change (only updated once per session from Firefox 56 on) out below in the detailed docs? I've reverted back to the previous message using the boolen flag to guard the updates: unfortunately, since updateSettings is always overwriting that section of the environment, getting around that is tricky and produces some test fallout. Let's defer that to the upcoming refactoring in bug 1372845.
Comment on attachment 8877523 [details] Bug 1367029 - Defer gathering isDefaultBrowser until session restore completes. https://reviewboard.mozilla.org/r/148976/#review153988 ::: toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js:1584 (Diff revision 4) > + Assert.ok("isDefaultBrowser" in environmentData.settings, > + "isDefaultBrowser must be available after the session is restored."); We should check that this has a reasonable value (non-null, right type).
Attachment #8877523 - Flags: review?(gfritzsche) → review+
Pushed by alessio.placitelli@gmail.com: https://hg.mozilla.org/integration/autoland/rev/adb51b322ca8 Defer gathering isDefaultBrowser until session restore completes. r=gfritzsche
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
Depends on: 1373913
Performance Impact: --- → P1
Whiteboard: [qf:p1]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: