已经用 golang:1.25 重新构建了,本以为运行时能识别到 2 个 CPU 的限制。pod 里还是打印 gomaxprocs=32 numcpu=32,而且每次运行 nr_throttled 都会涨几千。workers 从 16 降到 4,也只是把耗时从 9 分钟降到 7 分钟。我是漏了什么?谢谢。
FROM golang:1.25 AS build
...
RUN CGO_ENABLED=0 go build -o /manifestd .
module github.com/maxlab/manifestd
go 1.23.0
resources:
requests:
cpu: "1"
limits:
cpu: "2"
pod 的环境变量里没有设置 GOMAXPROCS,代码里也没有任何地方用具体的值调用 runtime.GOMAXPROCS。同一个二进制在我的 MacBook 上大约 2.5 分钟就跑完了。
从英语翻译·查看原文Rebuilt on golang:1.25 expecting the runtime to see the 2 CPU limit. The pod still logs gomaxprocs=32 numcpu=32 and nr_throttled climbs a few thousand per run. Workers 16 to 4 only took 9 min to 7. What am I missing? Thanks.
FROM golang:1.25 AS build
...
RUN CGO_ENABLED=0 go build -o /manifestd .
module github.com/maxlab/manifestd
go 1.23.0
resources:
requests:
cpu: "1"
limits:
cpu: "2"
No GOMAXPROCS in the pod env, and nothing in the code calls runtime.GOMAXPROCS with a value. The same binary takes about 2.5 min on my MacBook.