Closed Bug 1408729 Opened 7 years ago Closed 3 years ago

[OS.File] Loading osfile.jsm is slow

Categories

(Toolkit Graveyard :: OS.File, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: milindl, Unassigned)

References

Details

(Keywords: perf, Whiteboard: [fxperf:p2])

See Bug 1063635 See Bug 1063635#c10 This is done by lazily loading osfile (and its individual modules) if possible or investigating those functions which are called during startup.
Continuing the work from https://bugzilla.mozilla.org/show_bug.cgi?id=1063635#c8 of the given bug, some more results using perf-html profiler. * Currently, the first one to load osfile is GMPProvider.jsm followed by a very small usage by either CrashMonitor.jsm or SessionFile.jsm (varying on different startups). These seem to be the only users of the osfile in the first "event processing delay" on the main thread. Related profile: https://perfht.ml/2zDXoyL * On patching GMPProvider.jsm to use a `defineLazyModuleGetter`, the first one to load osfile is ExtensionParent.jsm, followed by some SessionFile.jsm or CrashMonitor.jsm. Note that this (ExtensionParent) was not there in the last profile in the first "event processing delay". Related profile: https://perfht.ml/2zDBsUw Based on this: 1. I'm unable to figure out why ExtensionParent is suddenly introduced to the startup even though it was not there previously (it uses a lazy getter as well already). Is there a way to investigate this? 2. I'm not sure why CrashMonitor and SessionFile only show up periodically (and in a seemingly random order). However, they seem to take up really small spaces on the time axis.
Flags: needinfo?(dteller)
Apologies for the deal, I didn't see that needinfo. It might just be that there are race conditions and the code doesn't always load in the same order. For the moment, the biggest gain would be obtained by delaying the load of osfile_*.jsm, so I'd start by attempting to blacklist one of these (using http://searchfox.org/mozilla-central/source/browser/base/content/test/performance/browser_startup.js ), then seeing what breaks and if it can be fixed.
Flags: needinfo?(dteller) → needinfo?(i.milind.luthra)

This is what loading OS.File currently looks like: https://bit.ly/3dzjmqA

That's too many JS modules loaded at once. Some could be loaded lazy, and the rest should likely be combined (maybe at build time) into a single one.

https://perfht.ml/2X8RCUc is what loading the OS File worker looks like. This calls ImportScripts 5 times, and the ImportScripts implementation requires a round trip to the main thread before returning, so we get stuck because the main thread is janky during startup.

It's unfortunate that we get stuck 3 times to import require.js (into different .jsm files).

Whiteboard: [fxperf]
Whiteboard: [fxperf] → [fxperf:p2]

Is this still important after the work being done in bug 1522925 and bug 986145?

Flags: needinfo?(florian)

I'll jump in here and say no - we're focusing on pulling OSFile.jsm out of the tree entirely, rather than optimizing it.

Flags: needinfo?(florian)
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → WONTFIX
Flags: needinfo?(i.milind.luthra)
Product: Toolkit → Toolkit Graveyard
You need to log in before you can comment on or make changes to this bug.