defold / extender

Native extension build server
https://defold.com/manuals/extensions/
MIT License
45 stars 19 forks source link

Make custom thread pool size configurable. #526

Closed ekharkunov closed 1 month ago

ekharkunov commented 1 month ago

To achieve sharing traceId and spanId across different thread's context custom task executor was implemented. By default it creates thread pool with size = 1.

A standard implementation of Spring's TaskScheduler interface, wrapping a native java.util.concurrent.ScheduledThreadPoolExecutor and providing all applicable configuration options for it. The default number of scheduler threads is 1; a higher number can be configured through setPoolSize.          <------------------------

This is Spring's traditional scheduler variant, staying as close as possible to java.util.concurrent.ScheduledExecutorService semantics. Task execution happens on the scheduler thread(s) rather than on separate execution threads. As a consequence, a ScheduledFuture handle (e.g. from schedule(Runnable, Instant)) represents the actual completion of the provided task (or series of repeated tasks).

As a result every build task that goes to remote build stall all other build task. So processing was almost single-threaded.

So fix add config option to allow set pool size from the application properties. By default pool size is 35. That pool size used for remote build/async build/scheduled task (like cleanup build folder, update users, etc.)

Also mark AsyncBuilder.asyncBuildEngine to use custom executor.