[Session Restore] Split SessionFile._writeState across several ticks

RESOLVED WONTFIX

Status

()

Firefox
Session Restore
RESOLVED WONTFIX
4 years ago
4 years ago

People

(Reporter: Yoric, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [Async:ready])

At the moment, SessionSaver._writeState does the following:
1. serialize |state| to JSON;
2. notify observers;
3. call SessionFile.write(state).

Operations 1., 2. and 3. can be slow. It would, however, considerably alleviate the issue if we could execute them in different ticks.
Marking this as a mentored bug.
The code lives here: http://dxr.mozilla.org/mozilla-central/source/browser/components/sessionstore/src/SessionSaver.jsm#288

This will require calling Services.tm.dispatch (http://dxr.mozilla.org/mozilla-central/source/xpcom/threads/nsIEventTarget.idl#30) to delay execution to the next tick and playing a little with Task.jsm and promise.
Whiteboard: [Async:ready][mentor=Yoric][lang=js][mentored but not simple]
Summary: [Session Restore] Split _writeState across several ticks → [Session Restore] Split SessionFile._writeState across several ticks
Do we have any data that tells us this is a thing we should do? Why not bring bug 944557 forward or add a telemetry measurement before doing this micro-optimization?

It seems like this will complicate enough code to become awkward. For SessionSaver.run() writes wouldn't be dispatched synchronously anymore which could lead to dataloss if AsyncShutdown doesn't know there is a pending write.
Ok, let's wait for Telemetry.
Whiteboard: [Async:ready][mentor=Yoric][lang=js][mentored but not simple] → [Async:ready]
Depends on: 962808
Indeed, looking at Telemetry, this doesn't look too useful.
Replaced by the almost equivalent but much more useful bug 984886.
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.