feat: run memtrack memory profiling without sudo via file capabilities#407
Conversation
Merging this PR will not alter performance
|
6b0e488 to
d729c92
Compare
Greptile SummaryThis PR replaces the previous
Confidence Score: 5/5Safe to merge. The capability grant is idempotent, best-effort, and falls back to root-mode if setcap or the filesystem don't cooperate; all changed code paths are well-tested. The xattr decoder correctly handles all three VFS capability revisions, the setcap spec is now derived from the same constant that drives verification (eliminating drift), and the run-time ensure_privileges() guard provides a hard stop before any eBPF load attempt. The only observations are style nits. No files require special attention. The Cargo.toml has a minor dependency-placement inconsistency (xattr in the wrong section), but it has no effect on correctness or macOS builds. Important Files Changed
|
fb4e5fa to
1f22d61
Compare
1f22d61 to
dc0f8a6
Compare
dc0f8a6 to
93f53cf
Compare
Raising RLIMIT_MEMLOCK requires CAP_SYS_RESOURCE, which unprivileged agents and many containers lack. On kernels >= 5.11 BPF memory is accounted against the cgroup, so the limit is irrelevant; treat a failed setrlimit as a warning instead of bailing.
Without an IPC server nothing toggles the tracking_enabled map, so the eBPF is_enabled() check drops every event. Enable tracking up front in that path.
codspeed setup --mode memory now grants codspeed-memtrack the capabilities it needs (cap_bpf, cap_perfmon, cap_dac_read_search, cap_sys_admin, cap_sys_resource) via setcap, idempotently and with a single sudo prompt. At run time the memory executor no longer wraps memtrack in sudo: it requires root or those capabilities, otherwise failing with guidance to run codspeed setup. Lets agents run memory benchmarks unattended. Related: COD-1801
setup status now prints a privileges line under the memory executor: satisfied when running as root or the codspeed-memtrack binary carries the required file capabilities, missing (with remediation) otherwise. Lets agents confirm sudo-less memory profiling is ready before a run. Related: COD-1801
memtrack-based memory profiling is Linux-only; the caps crate fails to build on macOS. Move caps/memtrack/ipc-channel to Linux-only dependencies and cfg-gate the memory module and its wiring so macOS builds compile.
93f53cf to
e2da80a
Compare
No description provided.