Open Bug 1361095 Opened 8 years ago Updated 3 years ago

[meta] Can nsContentPrefService avoid main thread IO before the first window is shown?

Categories

(Firefox :: General, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: florian, Unassigned)

References

(Blocks 1 open bug)

Details

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

See this profile captured during startup on the quantum reference hardware: https://perfht.ml/2p1EDjb 51ms of startup is waiting for a CreateFileW system call from mozilla::storage::Service::OpenDatabase / ContentPrefService__dbInit.
Related is bug 886907. Can we just rm -rf this code?
See Also: → killSyncContentPrefs
ni? to adw for comment 1.
Flags: needinfo?(adw)
(In reply to :Ehsan Akhgari (super long backlog, slow to respond) from comment #1) > Related is bug 886907. Can we just rm -rf this code? That bug removes synchronous usage of this db connection, but the connection will stay there to serve asynchronous usage. What we really want (in addition to bug 886907) is bug 887889, that would make all the I/O async. And then we should check if it's possible to delay the initialization of the service itself.
Depends on: 887889
(In reply to :Ehsan Akhgari (super long backlog, slow to respond) from comment #1) > Related is bug 886907. Can we just rm -rf this code? Sure.
Flags: needinfo?(adw)
Whiteboard: [qf] → [qf-]
Whiteboard: [qf-] → [qf:meta]
Here is a first-startup profile where this takes 958ms on the main thread: https://perfht.ml/2sfM8Yt
I'm not surprised, the service seems to use a transaction to migrate the schema, but not one to create it, see _dbCreate()! And moreover it sets "PRAGMA synchronous = OFF" AFTER doing all these expensive operations... If we fix bug 886907 then all the APIs are async and should be portable to Sqlite.jsm. In the meanwhile, a dumb workaround could consist in either setting PRAGMA synchronous = OFF before creating the schema and use the schema version to differentiate an existing file, or just wrap the schema creation in a transaction.
Here is another startup profile where this blocks us for 1617ms: https://perfht.ml/2uCYbfB
Keywords: perf
Whiteboard: [qf:meta] → [qf:meta] [fxperf]
Priority: -- → P3
(In reply to Marco Bonardo [::mak] from comment #6) > I'm not surprised, the service seems to use a transaction to migrate the > schema, but not one to create it, see _dbCreate()! And moreover it sets > "PRAGMA synchronous = OFF" AFTER doing all these expensive operations... > > If we fix bug 886907 then all the APIs are async and should be portable to > Sqlite.jsm. Hey look, this bug got fixed! How hard would it be to port the APIs to Sqlite.jsm and fix this bug, Marco? Florian, how bad is this problem in your recent startup profiles? Did this get fixed elsewhere? (Waiting with setting a priority based on this...)
Flags: needinfo?(mak77)
Flags: needinfo?(florian)
This is pretty much waiting for bug 887889, that has some recent activity. Maybe after bug 887889 there's still some small optimizations we can do here.
Flags: needinfo?(mak77)
(In reply to :Gijs from comment #8) > Florian, how bad is this problem in your recent startup profiles? Did this > get fixed elsewhere? Recent startup profiles show this database opened by ContentPrefService2 during FullZoom_init (from browser-fullZoom.js), started during _delayedStartup: https://perfht.ml/2BXYf15 This is after first paint and the current bug summary says "main thread IO before the first window is shown", so I would be OK with closing this bug as WFM. But it seems Marco has ideas to make this async, which would be much better, so we can morph the bug to that.
Flags: needinfo?(florian)
Keywords: meta
Performance Impact: --- → ?
Whiteboard: [qf:meta] [fxperf] → [fxperf]
Summary: Can nsContentPrefService avoid main thread IO before the first window is shown? → [meta] Can nsContentPrefService avoid main thread IO before the first window is shown?
Performance Impact: ? → ---
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.