You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "samueleresca (via GitHub)" <gi...@apache.org> on 2026/10/19 18:50:40 UTC
[PR] Make default `NumParallel` cgroup-aware. [arrow-go]
samueleresca opened a new pull request, #1384:
URL: https://github.com/apache/arrow-go/pull/1384
### Rationale for this change
Since Go 1.25+, `runtime.GOMAXPROCS(0)` is cgroup-aware. See [Release notes](https://go.dev/doc/go1.25#runtime).
`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()` to `NumParallel = runtime.GOMAXPROCS(0)`
### Are these changes tested?
Tested manually using:
```go
package compute_test
import (
"runtime"
"testing"
"github.com/apache/arrow-go/v18/arrow/compute"
)
func TestCgroupDemo(t *testing.T) {
t.Logf("NumCPU=%d GOMAXPROCS=%d DefaultExecCtx.NumParallel=%d",
runtime.NumCPU(), runtime.GOMAXPROCS(0), compute.DefaultExecCtx().NumParallel)
}
```
and running with and without the change:
```bash
go test -c -o /tmp/c.test ./arrow/compute
systemd-run --user --scope -q -p CPUQuota=200% /tmp/c.test -test.run CgroupDemo -test.v
```
### Are there any user-facing changes?
Yes, a small behavioural change to the default:
- When GOMAXPROCS is lower than the CPU count, whether set by the environment variable, set by a cgroup limit on Go 1.25 or later, or set in code before package init, the default `NumParallel` is now lower than before.
- The default is read once at package init. A later call to runtime.GOMAXPROCS(n) won't change it.
- Callers can still override it with `SetExecCtx` or `ExecCtx.NumParallel`.
- There are no API or signature changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(arrow/compute): respect GOMAXPROCS for default NumParallel [arrow-go]
Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade merged PR #1384:
URL: https://github.com/apache/arrow-go/pull/1384
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org