Hi 👋
a very common pattern I've spotted is to spawn cpu_count number of threads with multiprocessing library. That leaves you with cpu_count + 1 threads, but the main thread commonly tends to chill until the others are done, so that's mostly fine if cfs_quota / cfs_period is a whole number. One could guarantee no throttling by spawning cpu_count - 1 threads in such a scenario as well.
You run into a problem if cfs_quota / cfs_period isn't a whole number given ceiling the number has been a chosen strategy. If your threads hammer the cpu, you're guaranteed to be throttled, unless you spawn cpu_count - 2 or fewer threads.
I wonder whether this library could help alleviate this issue, by either providing an option to choose between ceil or floor or by having an option to return float from cpu_count function.
What do you think?
Hi 👋
a very common pattern I've spotted is to spawn
cpu_countnumber of threads with multiprocessing library. That leaves you withcpu_count + 1threads, but the main thread commonly tends to chill until the others are done, so that's mostly fine ifcfs_quota / cfs_periodis a whole number. One could guarantee no throttling by spawningcpu_count - 1threads in such a scenario as well.You run into a problem if
cfs_quota / cfs_periodisn't a whole number given ceiling the number has been a chosen strategy. If your threads hammer the cpu, you're guaranteed to be throttled, unless you spawncpu_count - 2or fewer threads.I wonder whether this library could help alleviate this issue, by either providing an option to choose between
ceilorflooror by having an option to returnfloatfromcpu_countfunction.What do you think?