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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
