diff --git a/test/pylib/resource_gather.py b/test/pylib/resource_gather.py index 81fc92adc9..2865dd85ac 100644 --- a/test/pylib/resource_gather.py +++ b/test/pylib/resource_gather.py @@ -279,13 +279,16 @@ def _is_cgroup_rw() -> bool: return False def propagate_subtree_controls(group: Path): - with open(group / 'cgroup.controllers', 'r') as f: - controllers = f.readline().strip() - if not controllers: - return - controllers = " ".join(map(lambda x: f"+{x}", controllers.split(" "))) - with open(group / 'cgroup.subtree_control', 'w') as f: - f.write(controllers) + # Only enable the memory controller. cpu.stat is available without + # enabling the cpu controller (it's base cgroup v2 accounting). + # Enabling all controllers (cpu, io, pids, etc.) adds unnecessary + # per-operation kernel overhead to child processes - in particular, + # the io controller adds accounting to every I/O operation. + with open(group / "cgroup.controllers", "r") as f: + if "memory" not in f.readline().split(): + return + with open(group / "cgroup.subtree_control", "w") as f: + f.write("+memory") def setup_cgroup(is_required: bool) -> None: diff --git a/test/pylib/runner.py b/test/pylib/runner.py index e139e6c6d2..688fd66b8a 100644 --- a/test/pylib/runner.py +++ b/test/pylib/runner.py @@ -304,8 +304,11 @@ def pytest_sessionstart(session: pytest.Session) -> None: if not is_xdist_worker and SCYLLA_TEST_CGROUP_BASE_ENV not in os.environ: setup_cgroup(is_required=True) setup_worker_cgroup() - _system_resource_monitor = SystemResourceMonitor(temp_dir) - _system_resource_monitor.start() + # System-wide resource metrics (CPU%, memory) are identical from any process. + # Only the master needs to record them. + if not is_xdist_worker: + _system_resource_monitor = SystemResourceMonitor(temp_dir) + _system_resource_monitor.start()