Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more priorities #1

Open
astoilkov opened this issue May 2, 2021 · 4 comments
Open

Add more priorities #1

astoilkov opened this issue May 2, 2021 · 4 comments
Labels
discussion Discussion

Comments

@astoilkov
Copy link
Owner

astoilkov commented May 2, 2021

Currently, I have added only two priorities to the library — background and user-visible. I feel this won't be enough. However, I can't imagine all the use cases the library will be used in. This is why I am starting a discussion here, so together, we can find the right priorities.

You can read more about priorities here and here.

@ScriptedAlchemy
Copy link

Wild idea, but would is be possible to do something like extend the delay adaptively? RIC does this but it's often too fast.

I've used algorithms that are able to calculate current CPU pressure. I mainly do this so I can block third party tags by monkey patching document.createElement. Then based of CPU pressure I can suspend the unblock rates till CPU isn't under so much stress.

Another one that might be interesting to consider is suspending when the user interacts with the page, scrolling or clicking around - tho some of this might be covered by by requestAnimationFrame

@astoilkov astoilkov added the discussion Discussion label Oct 27, 2021
@astoilkov
Copy link
Owner Author

Wild idea, but would is be possible to do something like extend the delay adaptively?

I like the idea. Maybe I can use it as a fallback when navigator.scheduling.isInputPending() isn't available. Do you have examples of a code that tries to do that? I will be interested in learning from it.

Another one that might be interesting to consider is suspending when the user interacts with the page, scrolling or clicking around - tho some of this might be covered by requestAnimationFrame

This is covered by navigator.scheduling.isInputPending() when available. When not available the library is a lot more conservative to do work without giving back control to userland.

@astoilkov
Copy link
Owner Author

astoilkov commented Feb 20, 2024

Wild idea, but would is be possible to do something like extend the delay adaptively?

I started experimenting with this. We will see how it goes.

I've used algorithms that are able to calculate current CPU pressure. I mainly do this so I can block third party tags by monkey patching document.createElement. Then based of CPU pressure I can suspend the unblock rates till CPU isn't under so much stress.

Is some part of that open-source? I would love to take inspiration.

@astoilkov
Copy link
Owner Author

My current idea is to use fps tracking: https://github.com/astoilkov/main-thread-scheduling/blob/980ad69b477779ff882eac16ac7cd2a60331e16c/playground/utils/fps.ts. If fps is low, I will spend less time in scheduled tasks. I will add an option to the yield methods where you can control the wiggle room in ms. What do you think @ScriptedAlchemy?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussion
Projects
None yet
Development

No branches or pull requests

2 participants