Repository navigation
fix(arrow/compute): respect GOMAXPROCS for default NumParallel - #1384
Conversation
zeroshade
left a comment
There was a problem hiding this comment.
Thanks. This is a sensible default now that Go 1.25+ makes GOMAXPROCS cgroup-aware, and go.mod already requires 1.26. I checked it locally: with GOMAXPROCS=2 the default NumParallel is 2, and under systemd-run -p CPUQuota=300% it's 3, where both runs previously gave 22 on this host. Callers can still override it through ExecCtx. One small thing: the title should follow the conventional-commit format in CONTRIBUTING.md; I'll adjust it on merge.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Arrow maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.More on how Apache Arrow handles maintainer review:
CONTRIBUTING.md.
NumParallel cgroup-aware.The runtime.NumCPU() vs runtime.GOMAXPROCS(0) change in DefaultExecCtx is out of scope for this PR (it was already addressed separately in apache#1384). Revert to upstream/main's runtime.GOMAXPROCS(0) to keep the PR diff focused on datum ownership semantics.
Rationale for this change
Since Go 1.25+,
runtime.GOMAXPROCS(0)is cgroup-aware. See Release notes.runtime.NumCPU()reflects the number of CPUs on the host without taking into account cgroup limits.The issue has an impact in any containerised environment (e.g., k8s) when setting limits.
What changes are included in this PR?
Switching from
NumParallel = runtime.NumCPU()toNumParallel = runtime.GOMAXPROCS(0)Are these changes tested?
Tested manually using:
and running with and without the change:
go test -c -o /tmp/c.test ./arrow/compute systemd-run --user --scope -q -p CPUQuota=200% /tmp/c.test -test.run CgroupDemo -test.vAre there any user-facing changes?
Yes, a small behavioural change to the default:
NumParallelis now lower than before.runtime.GOMAXPROCS(n)won't change it.SetExecCtxorExecCtx.NumParallel.