Yida Wu has uploaded a new patch set (#5). ( https://gerrit.cloudera.org/25261 )
Change subject: IMPALA-15587: Detect CPU cores Impala can run on ...................................................................... IMPALA-15587: Detect CPU cores Impala can run on CpuInfo::num_cores() is the number of CPU cores of the machine. In a container or under taskset, Impala can run on fewer cores than that, because of the CPU affinity mask of the process or the cgroup CPU limit. This adds CpuInfo::effective_num_cores(): the smallest of num_cores(), the number of cores in the CPU affinity mask from sched_getaffinity() and the cgroup CPU limit. The cgroup CPU limit is rounded up to whole cores, like the JVM's container support does, and is read from cpu.max on cgroup v2 and from cpu.cfs_quota_us and cpu.cfs_period_us on cgroup v1, by the new CGroupUtil::FindCGroupCpuLimit(). InitCommonRuntime() applies it with the new CpuInfo::LimitEffectiveNumCores(), since impala-profile-tool links CpuInfo but not CGroupUtil. If --num_cores is set, the effective number of cores is num_cores(). The affinity mask is allocated for all possible cores, so that sched_getaffinity() also works with more than 1024 cores. The effective number of cores is shown as "Effective Cores" in the CPU info of the debug web UI and in the log at startup, and each backend reports it to the cluster in the new MachineInfoPB.cpu_effective_num_cores. The cgroup CPU limit, or why it could not be read, is shown next to the cgroup memory limit in the "Process CGroup Info". num_cores() does not change, so nothing else that uses the number of cores changes. Testing: - Added BE tests for parsing cpu.max, for converting a CPU quota to cores, for reading the cgroup CPU limit of the test process and for CpuInfo::LimitEffectiveNumCores(), including --num_cores. - Checked manually that the effective cores follow taskset and a cgroup v1 CPU quota, and that --num_cores overrides them. Change-Id: I93b4e020e03225398eadbe1c84b975ae38c9d505 Assisted-by: Claude Opus 5.5 (Claude Code) --- M be/src/common/init.cc M be/src/service/impala-server.cc M be/src/testutil/cpu-util.h M be/src/util/cgroup-util.cc M be/src/util/cgroup-util.h M be/src/util/cpu-info.cc M be/src/util/cpu-info.h M be/src/util/proc-info-test.cc M be/src/util/sys-info-test.cc M common/protobuf/statestore_service.proto 10 files changed, 223 insertions(+), 1 deletion(-) git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/61/25261/5 -- To view, visit https://gerrit.cloudera.org/25261 To unsubscribe, visit https://gerrit.cloudera.org/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: I93b4e020e03225398eadbe1c84b975ae38c9d505 Gerrit-Change-Number: 25261 Gerrit-PatchSet: 5 Gerrit-Owner: Yida Wu <[email protected]> Gerrit-Reviewer: Impala Public Jenkins <[email protected]> Gerrit-Reviewer: Joe McDonnell <[email protected]> Gerrit-Reviewer: Michael Smith <[email protected]> Gerrit-Reviewer: Yida Wu <[email protected]>
