Open danxmoran opened 2 years ago
This is our current logic for CPU_COUNT:
Making that more robust would definitely be appreciated in a PR!
I also tripped over this today. As the circles in the CPython ticket demonstrate there isn't an unambiguous correct answer that can be calculated from cgroups which leaves us in a bit of a pickle. (Given how old cgroups are now, this is certainly frustrating!)
(C) Calculate based on cpu shares. While there are widely used conventions, this is not possible to calculate without ambiguity (jdk ripped theirs out). The user intend between cpu shares and limit is also ambiguous.
I lean somewhat towards (B) as a marginal improvement on the status quo that doesn't preclude later changes.
Describe the bug
I'm running Pants in k8s. The pod has 8 allocated CPUs. The host machine has 32 total cores.
I expected Pants to compute a default value of
8
forprocess_execution_local_parallelism
and4
forrule_threads_core
. Instead it computes respective defaults of32
and16
.Based on python/cpython#80235 it seems this might be a fundamental problem with
os.cpu_count()
. There is a comment at the bottom of that issue showing a work-around that's been implemented inpylint
- maybe Pants could do the same?Pants version
abf8b681858510d18a22d04c4de5548bbcbf3cd5 (on the 2.12.x branch, set via
export PANTS_SHA
)OS
Linux