Commit b2a6833
fix: use available_parallelism for container-aware thread detection
num_cpus::get_physical() reads /proc/cpuinfo which is not namespaced
in containers — it always returns the host's physical core count,
ignoring cgroup CPU quotas (docker --cpus, K8s resources.limits.cpu).
Use min(available_parallelism, get_physical()) instead:
- available_parallelism reads cgroup v1/v2 quota files, so it
respects container CPU limits
- get_physical caps to avoid SMT oversubscription on bare metal
- RAYON_NUM_THREADS still overrides everything
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent c724803 commit b2a6833
1 file changed
Lines changed: 13 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| 28 | + | |
| 29 | + | |
25 | 30 | | |
26 | | - | |
27 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
28 | 36 | | |
29 | 37 | | |
30 | 38 | | |
| |||
0 commit comments