react-lua icon indicating copy to clipboard operation
react-lua copied to clipboard

wrapPerformWorkWithCoroutine unnessarially creates a thread each time its called

Open gaymeowing opened this issue 3 months ago • 1 comments

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

gaymeowing avatar Oct 01 '25 14:10 gaymeowing

hi

felixrosmery2-dot avatar Oct 13 '25 00:10 felixrosmery2-dot