Closed Bug 1361087 Opened 4 years ago Closed 4 years ago

Loading osfile_shared_allthreads.jsm does main thread IO on Windows

Categories

(Toolkit :: OS.File, defect, P1)

x86_64
Windows 10
defect

Tracking

()

RESOLVED FIXED
mozilla55
Iteration:
55.5 - May 15
Tracking Status
firefox55 --- fixed

People

(Reporter: florian, Assigned: florian)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [qf][photon-performance])

Attachments

(1 file)

See this profile: https://perfht.ml/2p1uyD1

Loading osfile_shared_allthreads.jsm (which is done during early startup) initializes the OSFileConstantsService at http://searchfox.org/mozilla-central/rev/3dc6ceb42746ab40f1441e1e659ffb8f62ae78e3/toolkit/components/osfile/modules/osfile_shared_allthreads.jsm#94

This creates the nsSystemInfo service at http://searchfox.org/mozilla-central/rev/3dc6ceb42746ab40f1441e1e659ffb8f62ae78e3/dom/system/OSFileConstants.cpp#326

And in the profile linked above, this spends 276ms of startup time doing main thread IO in a gethostname call (we don't seem to use this information).

I think some of this should be lazy-ified, if not completely ifdef'ed out on Windows, as this comment makes me think this has very little value there:
  // Get the umask from the system-info service.
  // The property will always be present, but it will be zero on
  // non-Unix systems.
Whiteboard: [qf] → [qf][photon-performance]
Flags: qe-verify?
Priority: -- → P2
#ifdef-ing it away on Windows definitely makes sense.

I think that we could replace this directly with `nsSystemInfo::gUserMask`, which shouldnt' need to initialize the nsSystemInfo service.
Flags: needinfo?(florian)
Attached patch PatchSplinter Review
Attachment #8863871 - Flags: review?(dteller)
Assignee: nobody → florian
Status: NEW → ASSIGNED
See Also: → 1361495
(In reply to :Ehsan Akhgari (super long backlog, slow to respond) from comment #3)
> We sort of have the same bug in the download manager too!
> 
> <http://searchfox.org/mozilla-central/rev/
> ae8c2e2354db652950fe0ec16983360c21857f2a/toolkit/components/downloads/
> nsDownloadManager.cpp#3381>

Hopefully that download manager code doesn't run during early startup, so I don't think we really need to apply the fix there. Especially if bug 1361495 gets fixed.
Flags: needinfo?(florian)
Iteration: --- → 55.5 - May 15
Priority: P2 → P1
Comment on attachment 8863871 [details] [diff] [review]
Patch

Review of attachment 8863871 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/system/OSFileConstants.cpp
@@ +326,5 @@
>  
>    // Get the umask from the system-info service.
>    // The property will always be present, but it will be zero on
>    // non-Unix systems.
> +  // It's initialized before nsSystemInfo::Init, so we don't need to

Nit: instead of "It", writing `nsSystemInfo::gUserMask` might be clearer.

Also, the important part is that `nsSystemInfo::gUserMask` is already initialized, by `NS_InitXPCOM2` (iirc).
Attachment #8863871 - Flags: review?(dteller) → review+
Pushed by florian@queze.net:
https://hg.mozilla.org/integration/mozilla-inbound/rev/427d001e5539
Loading osfile_shared_allthreads.jsm should not initialize the system-info service (as it does main thread IO on Windows), r=Yoric.
https://hg.mozilla.org/mozilla-central/rev/427d001e5539
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
(In reply to :Ehsan Akhgari (super long backlog, slow to respond) from comment #3)
> We sort of have the same bug in the download manager too!
> 
> <http://searchfox.org/mozilla-central/rev/
> ae8c2e2354db652950fe0ec16983360c21857f2a/toolkit/components/downloads/
> nsDownloadManager.cpp#3381>

That code is no more used in Firefox, we now use jsdownloads.
...and now it's time to tackle bug 851471 and dependencies, as this unused code comes up all the time. I'll see what I can do today.
No longer blocks: photon-performance-triage
Flags: qe-verify? → qe-verify-
You need to log in before you can comment on or make changes to this bug.