Open Bug 1805400 Opened 2 years ago Updated 1 year ago

Executing DOM worker scripts is delayed by main thread availability

Categories

(Core :: DOM: Workers, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: bas.schouten, Unassigned)

References

Details

We wait until onStopRequest is executed before we deliver scripts for DOM workers to their execution threads. Because of this execution can be delayed quite significantly, this impacts the Monaco-Editor benchmark for example, a profile showing this can be found here: https://share.firefox.dev/3W1MTPk

Assuming moving onStopRequest off the content process main thread (https://mozilla-hub.atlassian.net/browse/FFXP-2060) will not be done in time for Speedometer 3 release we should consider alternative approaches for parsing and executing the script before the onStopRequest callback is processed on the main thread.

We can't execute anything before OnStopRequest, since that is when we know the script has been loaded.
Incremental parsing depends on whether JS supports that.

Depends on: 1351231
Whiteboard: [s3:p1] → [sp3:p1]

(In reply to Olli Pettay [:smaug][bugs@pettay.fi] from comment #1)

We can't execute anything before OnStopRequest, since that is when we know the script has been loaded.
Incremental parsing depends on whether JS supports that.

We just need something to tell us all the bytes of the file are in. OnStopRequest could be that thing but it could be anything if OnStopRequest has some main thread dependency. Signalling just the end of the document does not have a main thread dependency afaict.

But if there's traffic to the main thread for other reasons as well, the PFetch protocol sound like a good solution.

Anyhow, bug 1351231 should fix this for workers, or at least with that work we can change script loading to not be blocked.

Whiteboard: [sp3:p1] → [sp3:p1],[sp3:monaco-editor]

Bas, could you try to get a new profile? Bug 1351231 has landed on Nightly.
And I'm having trouble to get now a profile where a worker would spend too much time with Monaco-Editor.

Flags: needinfo?(bas)

Here is a new profile captured today with a current local mozilla-central build: https://share.firefox.dev/3I1cqmo

Eden, script loading is still blocked by the main thread? https://share.firefox.dev/3IoHazc

Flags: needinfo?(bas) → needinfo?(echuang)

P3/S3, but this is tracked also as a speedometer3 blocker.

Severity: -- → S3
Priority: -- → P3

Yes, I think script loading is still blocked by the main thread. Currently, PFetch only supports fetch() in the worker. But it is not too hard to support PFetch on worker script loading to make it off-main thread.

Flags: needinfo?(echuang)
Whiteboard: [sp3:p1],[sp3:monaco-editor] → [sp3-p1] [sp3-monaco-editor]

Monaco-editor is not part of the sp3

No longer blocks: speedometer3
Whiteboard: [sp3-p1] [sp3-monaco-editor] → [sp3-delete]
You need to log in before you can comment on or make changes to this bug.