feat(agent): migrate RaplCollector from MSR to powercap sysfs - #50
Conversation
FW-Nagorko
left a comment
There was a problem hiding this comment.
Overall a good rewrite, some notes left to be addressed.
Replace dirent/access with std::filesystem directory iteration, validate energy_uj readability via ifstream in DiscoverPackages, store zone paths as std::filesystem::path, and parse package-N names with std::regex.
|
Good call, thanks for the thorough review. Addressed the rest: switched discovery to std::filesystem, moved the energy_uj readability check into DiscoverPackages (via ifstream), path is now std::filesystem::path, and package names go through std::regex as you suggested. Left multi-socket and |
FW-Nagorko
left a comment
There was a problem hiding this comment.
after the changes, LGTM
|
Tested on my machine ✅ Ran into a permission issue at first - the agent needs to be run with This will be properly resolved once we do proper packaging as a systemd daemon/service - no need to block this PR on that. 😄 |
Background
Previously, package energy came from MSR registers via
/dev/cpu/*/msr, which typically requires root or elevated hardware access. Linux exposes the same counter through powercap sysfs (/sys/class/powercap/intel-rapl:*/energy_uj), which fits a daemon running as an unprivileged user with filesystem read access to those nodes.Summary
energy_ujunderintel-raplpackage zones.name(package-N); emit socket 0 only; handle counter wrap viamax_energy_range_uj.METRIC_TYPE_CPU_POWER_PACKAGEreports energy delta in joules per sample.