Linux上的cgroup感知可用并行度/硬件并发数
Bun: cgroup-aware AvailableParallelism / HardwareConcurrency on Linux

原始链接: https://github.com/oven-sh/bun/pull/28801

将 `navigator.hardwareConcurrency`(以及因此的 `os.availableParallelism()`)通过 `WTF::numberOfProcessorCores()` 进行导航,而不是使用内联的 `sysconf`/`sysctl`。在 Linux 上,这会利用 WTF 中的新的 `sched_getaffinity` + `cgroup cpu.max` 限制,因此使用 `--cpus=N` 的容器会报告 N 而不是主机核心数。

对不起。
相关文章

原文
Routes navigator.hardwareConcurrency (and therefore
os.availableParallelism()) through WTF::numberOfProcessorCores() instead
of an inline sysconf/sysctl. On Linux this picks up the new
sched_getaffinity + cgroup cpu.max capping in WTF, so containers with
--cpus=N report N instead of the host core count.
联系我们 contact @ memedata.com