metarhia / noroutine

Goroutine analogue for Node.js, spreads I/O-bound routine calls to utilize thread pool (worker_threads) using balancer with event loop utilization. 🌱
https://metarhia.com
MIT License
121 stars 11 forks source link

enhance worker balancing logic #34

Open mchekh opened 1 year ago

mchekh commented 1 year ago

This update introduces a more adaptive approach to task allocation. In cases where a worker is occupied processing synchronous code, instead of instantly assigning a task to the worker with the best yet ELU, the task will now attempt to find another available worker or wait for the first free worker. Workers captured from the pool on task invocation and will return back as soon as all synchronous code in the first event loop cycle is completed. In cases when tasks consist of periodic asynchronous and large blocking operations some other tasks can be trapped but one of the next tasks will capture the worker until starts executing, in addition to ELU balancing it gives more smooth distribution and makes allocation more durable to the task fluctuations.