-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
The Default dispatcher in JS yields every 16 message, but it is not configurable easily.
This is an issue, because the impact in a browser can be dramatic when a large number of coroutines are manipulating the DOM,
as the browser will repaint every 16 messages.
16 is arbitrary, it is not a good or bad number as such, but since it can have a significant impact on performance, on user-experience, this should be configurable, no?
I suppose we can provide a custom Dispatcher, but the existing ones are fine, but it is internal/private.
Activity
mvanassche commentedon Aug 22, 2023
Actually, what I probably need is a different kind of queue, based on time: yield back to "JS macrotask event loop" minimum after a certain duration.
mvanassche commentedon Aug 23, 2023
I created a specific dispatcher that is time based, and allows to yield back to the browser after so many milliseconds (for example after 10ms, then 100ms then 500ms)
qwwdfsad commentedon Aug 28, 2023
For things like timings, it's indeed preferable to introduce your own dispatcher, I believe we cannot introduce a general enough mechanism that fits them all.
It's indeed arbitrary. Changing the hardcoded constant is fine (e.g. based on a versatile benchmarks suite or overall ecosystem observations), but making it configurable is much harder -- because different libraries might have different opinions on what this constant should be. This path is more or less explored with plugguble RxJava default schedulers and we would like to avoid that
mvanassche commentedon Aug 29, 2023
Ok, I understand, thank you.
It would be nice to expose some abstract
WindowDispatcher
/WindowMessageQueue
such that it is easier to implement a customMessageQueue
.