top | item 41219307

(no title)

lcof | 1 year ago

On Linux, go uses sched_getaffinity to know how many cpu core it is allowed to run on:

https://cs.opensource.google/go/go/+/master:src/runtime/os_l...

discuss

order

eadmund|1 year ago

> > On servers with 100+ cores I have seen scheduling time take over 10% of the program runtime.

> On Linux, go uses sched_getaffinity …

Since cgroups are a Linux-only feature, OP must be running Linux. I wonder if his experience pre-dates Go’s usage of sched_getaffinity.

edit: I realised that he references cgroups so must be on Linux.

Thaxll|1 year ago

This is not group aware.

lcof|1 year ago

if you want to limit the number of Ps, then you use a cpuset, that sched_getaffinity will take into account. cgroups only allows you to limit cpu usage, but not lower the number of cpu cores the code can run on. This is “how many” versus “how much”, and GOMAXPROCS only relates to the “how many” part.

I may have misunderstood the rationale here, but I think the discussion about cgroup support is not about limiting the number of Ps