Racct (Resource Accounting) Bug Fixes and Improvements
Contact: Cyril Zhang <cyril@freebsdfoundation.org>
racct is a resource accounting system in the FreeBSD kernel. It keeps track of resource usage, such as memory use and CPU runtime. Additionally, it provides an easy interface for limiting the resource usage of entities such as users and, importantly, jails. For example, it may be of interest to set a limit on the number of CPUs that a jail can use.
I have been discussing with other FreeBSD developers the prospect of adding racct support as an experimental feature to an OCI-compliant container runtime, runj by Samuel Karp. This would mimic Linux’s cgroups functionality in the OCI specification, which allows Linux containers to have limits on memory, CPU usage, etc. It also allows us to consider the possibility of adding FreeBSD-specific configuration to the OCI specification. As part of this work, I have been improving racct so that it is more functional for use with jails.
Improvements include:
-
A new, more accurate scheme for calculating total CPU usage of all processes in a jail
-
Fixing a bug that incorrectly counted the runtime of all child processes in the parent’s runtime
-
Fixing a bug that incorrectly decremented the count of persistent resources, such as shared memory, when a process exits
-
Accounting for POSIX features like shared memory and semaphores, where previously only SysV features were accounted for
-
Adding tests
Feel free to get in touch.
Sponsor: The FreeBSD Foundation
Last modified on: July 24, 2021 by Daniel Ebdrup Jensen