Open Bug 1544019 Opened 5 years ago Updated 11 months ago

Consolidate IO for startupCache folder access

Categories

(Core :: XPCOM, defect)

defect

Tracking

()

Performance Impact medium
Tracking Status
firefox68 --- affected

People

(Reporter: Gijs, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: main-thread-io, perf, perf:startup, Whiteboard: [fxperfsize:M] )

Attachments

(2 files, 1 obsolete file)

Windows IO markers for my profile show:

  • 2 stat calls on the directory, both from the CopyMove call that entails an Exists (one for the parent process cache, one for the child process one)
  • 7 (!) create/open calls on the directory:
    1. The first and fourth from GetCacheFile which calls create() itself.
    2. The second, third, fifth and sixth due to bug 1544009 and the MoveTo call in ::OpenCache;
    3. The 7th from our own Create call.

This is clearly suboptimal, and probably costs a few ms on spinny disk devices.

See Also: → 1544034

Access is in different places so not sure how hard this would be, tentatively picking medium t-shirt size (1-2 weeks).

Whiteboard: [fxperf] → [fxperf][fxperfsize:M]
Whiteboard: [fxperf][fxperfsize:M] → [fxperf:p2][fxperfsize:M]

bug 1544009 landed before the startup mainthread IO test. I think out of:

(In reply to :Gijs (he/him) from comment #0)

  • 2 stat calls on the directory, both from the CopyMove call that entails an Exists (one for the parent process cache, one for the child process one)

These should be fixed because https://hg.mozilla.org/mozilla-central/rev/8ccd4b2a5fba#l1.136 moved the exists() check behind a check so they shouldn't happen for the MoveTo calls on Windows, and we never did this on *nix, as far as I can tell from reading the linux/unix ::moveto implementation.

  • 7 (!) create/open calls on the directory:
    1. The first and fourth from GetCacheFile which calls create() itself.

This is still here.

2. The second, third, fifth and sixth due to bug 1544009 and the [MoveTo](https://searchfox.org/mozilla-central/rev/6dab6dad9cc852011a14275a8b2c2c03ed7600a7/js/xpconnect/loader/ScriptPreloader.cpp#431-432) call in `::OpenCache`;

These should be fixed by that bug.

3. The 7th from our own [`Create`](https://searchfox.org/mozilla-central/rev/6dab6dad9cc852011a14275a8b2c2c03ed7600a7/startupcache/StartupCache.cpp#173-174) call.

This is still here.

I checked the above with the profiler on a more recent build.

So this leaves 3 create calls:

I'm minded to suggest having a static method on StartupCache() called GetAndMaybeCreateCacheFolder() that gets and creates the folder once, caching the xpcom ref and handing out clones, and call that from the script preloader. :froydnj, does that sound like an OK solution?

Flags: needinfo?(nfroyd)

(In reply to :Gijs (he/him) from comment #2)

I'm minded to suggest having a static method on StartupCache() called GetAndMaybeCreateCacheFolder() that gets and creates the folder once, caching the xpcom ref and handing out clones, and call that from the script preloader. :froydnj, does that sound like an OK solution?

Yes. Eliminating the nasty duplication between the startup cache and the script preloader sounds like enough of a win here.

Flags: needinfo?(nfroyd)
Assignee: nobody → ccheung256
Status: NEW → ASSIGNED
Attachment #9072870 - Attachment is obsolete: true
Performance Impact: --- → P2
Keywords: perf:startup
Whiteboard: [fxperf:p2][fxperfsize:M] → [fxperfsize:M]

The bug assignee didn't login in Bugzilla in the last 7 months.
:nika, could you have a look please?
For more information, please visit auto_nag documentation.

Assignee: ccheung256 → nobody
Status: ASSIGNED → NEW
Flags: needinfo?(nika)

Gijs, Is this something we still want to push forward with?

Flags: needinfo?(nika) → needinfo?(gijskruitbosch+bugs)

(In reply to Nika Layzell [:nika] (ni? for response) from comment #8)

Gijs, Is this something we still want to push forward with?

This got marked as a perf P2, so I think so? Florian, can you corroborate?

Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(florian)
Severity: normal → S3

(In reply to :Gijs (he/him) from comment #9)

(In reply to Nika Layzell [:nika] (ni? for response) from comment #8)

Gijs, Is this something we still want to push forward with?

This got marked as a perf P2, so I think so? Florian, can you corroborate?

Yes, I see nothing that indicates this would have lost importance (but I haven't tried to reproduce recently either).

Flags: needinfo?(florian)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: