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

add new view to balancing #29

Open vsawake opened 1 year ago

vsawake commented 1 year ago

Create zones with weights depend on current utilization sum previous weight +(1-U)*WIDENING and choose worker depend on random int from 0 to max weight

tests: not sure how to test with random: pls advice, what I need to cover by tests changelog.md: will update if PR will generally approved

tshemsedinov commented 1 year ago

See this https://youtu.be/qipIRQptP_4

vsawake commented 1 year ago

https://youtu.be/qipIRQptP_4 ~38:00 (more 1:18:00)

  1. First balancing makes the calculation of weights without using ELU. Example [250,500,750,1000] for 4 worker threads
  2. Next balancing uses (1.01 - delta ELU).
  3. Balancing extends working intervals to [0,1000(WIDENING)] for easy selection, so we always receive [X,Y,Z,1000] for 4 worker threads. Example:

Reason for using 1.01 (possible 1.1 would be better)

Test (calculate checksum for all files in /user):

without: ~57s

old version: ~55s files per thread: [ 28800, 26300, 27277, 23000 ] active: [ 18740.3154, 7710.0067, 9252.7903, 6951.1388] idle: [ 35079.1447, 46123.5110, 44574.0218, 46858.2439 ]

new: ~36s files per thread: [ 26522, 37433, 29558, 11897 ] active: [ 24503.9996, 19966.9119, 19960.0115, 28230.7962 ] idle: [ 12138.4605, 16691.6788, 16691.0947, 8414.3918 ]