-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Currently in the default host config for the scheduler, a new thread is made each time wrapPerformWorkWithCoroutine() is called.
When this is unnecessary given performWorkUntilDeadline() already uses xpcall and handles errors (not if ReactGlobals.__YOLO__ is disabled but that can be changed), and an inlined version could be used in wrapPerformWorkWithCoroutine() with coroutine.yield() replacing the use of error(), or alternatively dependency injection could be used for providing a function to be used like how error() is currently in performWorkUntilDeadline().
Thread Pooling would also then be used for wrapPerformWorkWithCoroutine() as to handle the cases where the scheduledHostCallback yields (fairly certain it can?).
I haven't tested the performance impact this makes, but I would expect it to not be insignificant given threads are one of the most heavy things memory wise and for the GC. Especially as the function returned by wrapPerformWorkWithCoroutine is called frequently as its part of the scheduler.
Edit: Will be testing eventually when I get the time