WICG / scheduling-apis

APIs for scheduling and controlling prioritized tasks.
https://wicg.github.io/scheduling-apis/
Other
909 stars 45 forks source link

Can scheduler.yield() return additional information? #108

Open marco-prontera opened 1 month ago

marco-prontera commented 1 month ago

I'm speaking to you as a third-party developer creating scripts that run on a wide variety of websites. I'm currently at a stage where I need to gather detailed performance data. The more information I can collect, the more specific and valuable recommendations I can provide to my customers.

In particular, I'd like to better understand what happens between the moment a scheduler.yield() call is made and when execution resumes. While I can already measure the duration of this pause, I want to go further by identifying what happens during that time. This could offer insights into optimizing specific parts of a website and its integrations.

Since third-party scripts run on various websites where we don't have prior knowledge of their implementation, I believe we share common goals:

By understanding the actions that take place during the pause created by scheduler.yield(), I believe I can significantly improve how the product interacts with different websites and enhance overall performance and integration efficiency.

mmocny commented 1 month ago

Are you aware of the Long Animation Frames (LoAF) api (spec)?

It already does "long script monitoring" whenever:

marco-prontera commented 1 month ago

Can I use it to precisely detect what happens, even if there isn't a LoAF, from the point of the yield call until my code resumes execution?

shaseley commented 1 month ago

Tracing of some sort seems like it would be helpful. Could you maybe use the JS Self-Profiling API to collect traces during this period? (The availability is currently limited to Chromium-based browsers).

marco-prontera commented 1 month ago

I'll try to use the JS Self-Profiling API, I'll update you as soon as I can. Thank you!