black-sat/black

Support cgroups v2 in run benchmarks script

Closed this issue · 1 comments

At the moment the script /benchmarks/run uses cgroups v1 to limit the memory usage during benchmarks. However it would be nice to enable cgroups v2 support too.

Motivation

https://www.redhat.com/sysadmin/fedora-31-control-group-v2
https://www.redhat.com/en/blog/world-domination-cgroups-rhel-8-welcome-cgroups-v2
https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html

Workarounds

If not interested in limiting resources:

  • If libcgroup is not installed the memory limit is not set.
  • Thanks to #32 can be executed export MCAP=false before running the script to manually disable cgroup usage.

If interested in limiting resources

  • Force the use of cgroups v1, e.g. explained here.
  • To actually use cgroups v2 can be used a wrapper command, for example exploiting systemd in this way:
    systemd-run --user --scope -p MemoryHigh=60% -p MemoryMax=70% <actual-command>
    more details on parameters can be found here. Note that the MemoryHigh parameter make the system trying to keep the process under control. If one wants to put an hard limit on the memory usage, it should be used systemd-run --user --scope -p MemorySwapMax=0 -p MemoryMax=4G <actual-command>. The MemorySwapMax it's necessary to prevent the system to start swapping when the limit is reached.

This has been done as part of #69 .