Skip to content

wrapPerformWorkWithCoroutine unnessarially creates a thread each time its called #9

@gaymeowing

Description

@gaymeowing

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions