Open Bug 1505572 Opened 6 years ago Updated 7 months ago

get*State should return an object instead of a serialized string

Categories

(Firefox :: Session Restore, enhancement, P2)

enhancement

Tracking

()

Performance Impact low
Tracking Status
firefox65 --- affected

People

(Reporter: Gijs, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: perf:resource-use, perf:responsiveness)

All the non-sessionstore consumers of these methods immediately parse the JSON back out again. This is a waste of CPU cycles (encoding and then immediately decoding again). We should just expose a non-JSON API.

Mike, do you know why these APIs return JSON at all? Is it just for IPC purposes or something? Or to avoid consumers changing the values when we pass object references, or something else?
Flags: needinfo?(mdeboer)
(In reply to :Gijs (he/him) from comment #0)
> Or to avoid consumers changing the values when we
> pass object references, or something else?

This. At the moment I can't really think of a way to do this other than using `Cu.cloneInto` to make a structured clone (copy) of the data.
Flags: needinfo?(mdeboer)
(In reply to Mike de Boer [:mikedeboer] from comment #1)
> At the moment I can't really think of a way to do this other than
> using `Cu.cloneInto` to make a structured clone (copy) of the data.

Yes, but (as I'm sure you know) that should still be measurably faster than doing that via JSON.parse(JSON.stringify()) :)
Indeed, so I'd be very happy to see that change. I can work on that somewhere in the future, but perhaps else can find the cycles before I can...? ;-)
Blocks: ss-perf
Priority: -- → P2
Whiteboard: [fxperf] → [fxperf:p2]
Whiteboard: [fxperf:p2] → [fxperf:p3]
Depends on: 1730477
Depends on: 1733422
Depends on: 1733425
Severity: normal → S3

We also have structuredClone now.

Performance Impact: --- → low
Whiteboard: [fxperf:p3]

I think this might be WFM? Mark did a bunch of heroic work around this, IIRC.

Flags: needinfo?(standard8)

(In reply to Mike Conley (:mconley) (:⚙️) from comment #4)

We also have structuredClone now.

The bugs we've already fixed here, switched to using Cu.cloneInto, since that's what was already being used in the non-string cases. I'm not sure which is better between the two for this case.

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

I think this might be WFM? Mark did a bunch of heroic work around this, IIRC.

There's still two functions to do:

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