lxc / lxcfs

FUSE filesystem for LXC
https://linuxcontainers.org/lxcfs
Other
1.02k stars 246 forks source link

Allow scheduler to chose cpu cores while being limited to given number. #616

Closed tomtom13 closed 8 months ago

tomtom13 commented 8 months ago

Hi, It's my understanding, however I might be wrong, that when providing limit on cores for the container - container will get pinned to specific cores without ability to move to different cores depending on load. This poses problems on cpu's that have P&E cores, where container can get allocated hyper-threaded cores which have very poor performance (about 30% of main core ?).

stgraber commented 8 months ago

That's a kernel limitation, not a limitation of lxcfs. In fact lxcfs doesn't even apply any of those limits, it merely shows you the result of those limits.

There are two ways to limit CPUs in the kernel, a cpuset which is a static list of cores that can be used (as you described) or CFS quotas. CFS quotas (limits.cpu.allowance in Incus) let you apply limits of time rather than limits of specific CPUs.

So instead of limits.cpu=4, maybe use limits.cpu.allowance=40ms/10ms, this will time-limit your CPU usage at 4 CPUs worth of time, considered over a time slice of 10ms but allow the scheduler to pick any core it sees fit.