Skip to content

Commit

Permalink
refactor cgroup to allow multiple properties per controller
Browse files Browse the repository at this point in the history
The previous Cgroup implementation used a separate object per
every cgroup property. This lead to additional calls to
create_dir_all and writes to cgroup.procs, especially in
cgroupsv2 where there is only one hierarchy.

This change prevents the duplication by refactoring the code into:
 - CgroupConfiguration: this holds multiple cgroup properties in
     multiple cgroup controllers and hierarchies
 - Cgroup: this holds the configuration for a hierarchy and holds
     multiple properties
 - CgroupProperty: a file to value mapping of the cgroup properties
     to be written.

The CgroupBuilder is changed to a CgroupConfigurationBuilder so that
the setup of the Cgroup is abstracted away from the environment.

Additionally, in the CgroupV2 the available controllers read from
cgroup.controllers are cached to avoid multiple unnecessary reads.

Signed-off-by: Riccardo Mancini <mancio@amazon.com>
  • Loading branch information
mancio-aws committed Jan 19, 2024
1 parent 256e402 commit c46ca08
Show file tree
Hide file tree
Showing 2 changed files with 229 additions and 158 deletions.

0 comments on commit c46ca08

Please sign in to comment.