Yida Wu has uploaded a new patch set (#2). ( 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 cores in the CPU affinity mask from
sched_getaffinity() and the cgroup CPU limit, rounded up. The cgroup
CPU limit 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 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. num_cores() does not change,
so nothing else that uses the number of cores changes.

Testing:
- Added BE tests for parsing cpu.max and for converting a CPU quota
  to 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/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 common/protobuf/statestore_service.proto
8 files changed, 156 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/61/25261/2
--
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: 2
Gerrit-Owner: Yida Wu <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>

Reply via email to