Set Ruby Thread priority based on content being processed
We can greatly affect the latency and duration of jobs by tinkering with the thread priorities.
Now, since we have Sidekiq attributes we can set a designated thread priority based on expectation how quickly given thread needs to be processed or finished. Now, if we would be able to do the same for Puma and web requests we could improve the performance of some, but make others other threads to be picked less.
The thread priority does affect how big time slice does thread receive when running work item:
We can give super high priority for every thread that is asking for new jobs/requests, and then we can adjust the priority up/down based on type of workload and how big guarantees we give for given type of workload.
The current slice is 10 ms
(unless IO happens), we can reduce or increase it as we wish with priority.
It means that the smallest increase of latency in such case that we expect gonna be the 10 ms,
unless we change the slice with priority.