Skip to content

feat(daemon): report resident memory in info/status (#1785) - #1786

Merged
zackees merged 2 commits into
mainfrom
agent/daemon-rss
Oct 29, 2026
Merged

zackees merged 2 commits into
mainfrom
agent/daemon-rss

Conversation

@zackees

@zackees zackees commented Oct 29, 2026

Copy link
Copy Markdown
Member

What

fbuild-daemon now reports its own resident memory, so leak reports carry numbers instead of a screenshot from another tool (#1785, parent #1360).

  • fbuild_core::platform::process::resident_memory(pid) — new neutral capability returning MemoryUsage { resident_bytes, peak_resident_bytes }. Implementations live only in the platform tree:
    • Linux — VmRSS / VmHWM from /proc/<pid>/status (KiB, checked multiply).
    • macOS — proc_pidinfo(PROC_PIDTASKINFO) for the resident size; getrusage(RUSAGE_SELF) for the peak of this process (macOS has no per-pid high-water mark, so a foreign pid reports peak = None).
    • Windows — GetProcessMemoryInfo via PROCESS_QUERY_LIMITED_INFORMATION.
  • Absence is a value: pid 0, a missing /proc entry, a denied task port, or a failed OpenProcess all yield None — never 0 B.
  • GET /api/daemon/info gains rss_bytes and peak_rss_bytes (both skip_serializing_if = None, so older clients see no change).
  • daemon_status.json gains the same two fields and StatusManager::refresh_memory(), called from the existing 1 s maintenance loop at a 10 s cadence. This is the half that survives a wedged daemon: /health stops answering, the last good sample stays on disk.
  • fbuild daemon status prints Memory: 84.2 MB (peak 181.8 MB). The peak suffix is only shown when it exceeds the current sample.

Why the status file matters

#1360's evidence problem was that every existing sample was external (tasklist, ps, /proc) taken after the fact. A daemon that has stopped answering HTTP still leaves its last memory sample on disk, and the next fbuild daemon status reads it.

Tests

  • platform::process: current process reports a positive resident set with peak >= rss; pid 0 reports nothing.
  • platform::linux: /proc/<pid>/status line parsing (KiB suffix required, ""/MB rejected), missing pid → None, own process → positive rss + VmHWM.
  • status_manager: memory round-trips through the status file; a legacy daemon_status.json without the fields still deserialises; the peak never moves backwards across refreshes.
  • models: /api/daemon/info serialises both fields.
  • fbuild daemon status: memory_label formatting with and without a released peak.

Gates: bash test, clippy --workspace --all-targets -- -D warnings, fmt, ci/run_dylint for core/daemon/cli, ci/enforce_platform_boundary.py --print-totals (44/0), ci/check_test_layout.py.

Not in this PR

No Windows/macOS runtime verification of the numbers (only cross-target check on x86_64-pc-windows-msvc and x86_64-apple-darwin); the Linux path was exercised against a live daemon. Nothing here changes what the daemon does with the numbers — sampling cadence and thresholds stay for #1360's follow-up.

The daemon now measures its own resident set instead of leaving every leak
report to an external sampler taken after the fact.

- fbuild_core::platform::process::resident_memory(pid) returns
  MemoryUsage { resident_bytes, peak_resident_bytes }; the implementations
  live only in the platform tree (Linux /proc VmRSS/VmHWM, macOS
  proc_pidinfo + getrusage for self, Windows GetProcessMemoryInfo).
- Absence is None, never 0: pid 0, a missing /proc entry, a denied task
  port, or a failed OpenProcess.
- /api/daemon/info gains rss_bytes and peak_rss_bytes (skipped when None).
- daemon_status.json gains the same fields, refreshed by
  StatusManager::refresh_memory() from the existing maintenance loop at a
  10 s cadence, so the last sample survives a wedged daemon.
- fbuild daemon status prints "Memory: 97.0 MB (peak 188.1 MB)".
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@zackees
zackees added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit f2f6883 Oct 29, 2026
28 checks passed
@zackees
zackees deleted the agent/daemon-rss branch October 29, 2026 17:11
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant