As I understand it (please correct me if I'm wrong),

systemctl set-property ... CPUShares=some_value

limits the cpu time for an entire cgroup unit. If we instead want to limit cpu time for a process within that unit, we can run the process with

systemd-run ... nice=some_value

I'm wondering if there's some intrinsic difference between the concepts of the nice-value of a process and the CPUShares-value of a group of processes? Can we limit CPUShares of a process, or set the nice-value of a cgroup unit? When would we want to do one or the other?

up vote 7 down vote accepted

From reading man systemd-run, it will create a service and thus a cgroup on the fly. From reading systemd.exec, the Nice= directive will apply to all executed processes, so the way that systmd handles the concepts of Nice= and CPUShares= are very similar.

My understanding of the relationship is that it has to do with history. nice has existed for a listed a couple of decades and always applied to specific processes.

On the other hand, the concept of cgroups and the idea of applying CPUShares= to a process group is much a newer concept but accomplishes the same goal.

I expect systemd supports Nice= for historical compatibility.

I would use whichever one you are comfortable with, but not both to avoid confusion. If you have no preference, I would use the newer CPUShares= concept.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.