Closed Bug 1667903 Opened 4 years ago Closed 2 years ago

Processing scripts should be done as prioritized runnables

Categories

(Core :: Performance, enhancement, P2)

enhancement

Tracking

()

RESOLVED WONTFIX

People

(Reporter: denispal, Assigned: denispal)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

Scripts executed by the script loader are done serially in ProcessPendingRequests(), or as a Runnable if it was an async or blocking script that was compiled off thread.

In the first case, we could get stuck in an ugly situation where there are multiple scripts pending and we continuously execute them blocking the main thread from other work. This may also be especially likely now that we parse more scripts speculatively from bug 1606652. Instead, requests should only be pending if they are not ready to execute yet, and dispatched as runnables with the proper dependencies between them when they are.

In addition, scripts should be assigned priorities so they do not compete with one another and other tasks such as painting. A first suggestion would be to mark async scripts as low priority and blocking/defer scripts as medium. Painting should always take priority over script execution.

We'll also need to do this so that we can speculatively parse async and link preload scripts.

Blocks: 1667904

Hi Denis could you set a priority and severity for this bug - it's showing up in triage. thanks!

Flags: needinfo?(dpalmeiro)
Severity: -- → N/A
Flags: needinfo?(dpalmeiro)
Priority: -- → P2
Attachment #9189205 - Attachment description: Process script requests as prioritized tasks → (WIP - prototype) Process script requests as prioritized tasks
Blocks: 1687973

JS script executions currently occur immediately when they are able to do so. Sometimes, this can lead to the blocking of other tasks. Instead, dispatch them as Tasks. This will also open the door for further work in speculating async and link preload compilations, but setting the execution priority of those scripts as low so they do not block execution of more important scripts needed during page load.

Attachment #9189205 - Attachment is obsolete: true

Is bug 1514011 kind of a dup of this? Splitting execution to tasks, so that paint may happen at better time.

Yeah I think they are certainly similar. If we can make the executions tasks then we can start thinking about delaying them and prioritizing them with other work. We could also even explore building a history of how long each script takes to run and then use those estimates to schedule around them or force a paint before hand.

Hi Denis, what do you think of the performance impact of this bug?
Also, I noticed you have an old patch up for it.

Flags: needinfo?(dpalmeiro)

I think we can probably cancel this bug. I have a more up to date patch somewhere, but I wasn't actually able to measure any wins locally so it didn't seem worth the risk.

Status: NEW → RESOLVED
Closed: 2 years ago
Flags: needinfo?(dpalmeiro)
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: