docs: refine worker choice strategies README
[poolifier.git] / src / pools / selection-strategies / README.md
CommitLineData
9e2ab226
JB
1# Worker choice strategies
2
c63b7b38
JB
3All duration or timestamp are expressed in milliseconds.
4
9e2ab226
JB
5## Strategies
6
7### Fair share
8
9Its goal is to distribute the load evenly across all workers. To achieve this, the strategy keeps track of the average task execution time for each worker and assigns the next task to the worker with the lowest task end prediction time: `task_end_prediction = max(current_time, task_end_prediction) + average_task_execution_time`.
f1c06930 10By default, the strategy uses the average task execution time for each worker but it can be configured to use the task event loop utilization (ELU) active time instead.
9e2ab226
JB
11
12### Weighted round robin
13
251f0d71 14The worker weights are maximum tasks execution time, once the worker has reached its maximum tasks execution time, the next task is assigned to the next worker. The worker default weights are the same for all workers and is computed given the CPU cores speed and theirs numbers.
afe102b2 15
9e2ab226
JB
16### Interleaved weighted round robin
17
251f0d71 18The worker weights are maximum tasks execution time. The rounds are the deduplicated worker weights.
12d8ed1b 19During a round, if worker weight is inferior to the current round, the next task is assigned to the next worker. Once all workers have been assigned a task, the next round starts.
251f0d71
JB
20The worker default weights are the same for all workers and is computed given the CPU cores speed and theirs numbers. So the default rounds consists of a unique worker weight.
21
9e2ab226
JB
22## Statistics
23
afe102b2
JB
24Worker choice strategies enable only the statistics that are needed to choose the next worker to avoid unnecessary overhead.
25
9e2ab226
JB
26### Median
27
c63b7b38 28Strategies using the average task execution time for each worker can use the median instead. Median is more robust to outliers and can be used to avoid assigning tasks to workers that are currently overloaded. Median usage introduces a small overhead: measurement history must be kept for each worker and the median must be recomputed each time a task has finished.