Skip to content

Add memory_exclude_file_cache option - #220

Open
simontims wants to merge 1 commit into
ualex73:masterfrom
simontims:memory-exclude-file-cache
Open

simontims wants to merge 1 commit into
ualex73:masterfrom
simontims:memory-exclude-file-cache

Conversation

@simontims

Copy link
Copy Markdown

Add memory_exclude_file_cache option

Memory usage is currently usage - inactive_file (the same as docker stats). On cgroup v2 hosts, active page cache stays in the number, so a container that has just read large files shows hundreds of MB that its processes don't hold, and the kernel can reclaim at any time.

Example from one host (MB):

container current with option process memory (anon)
immich_machine_learning (after loading models) 863 124 94
puppeteer screenshot service 336 40 33
music-assistant 3957 2030 1971

This adds a per-instance option, default false, so existing behaviour is unchanged:

monitor_docker:
  - name: Docker
    memory_exclude_file_cache: true

When true, all file cache is subtracted: file on cgroup v2, total_cache / cache on cgroup v1. The percentage sensor follows, since it is derived from the same usage value. README and info.md document the option.

Tested on Home Assistant 2026.10.4 (Container), Docker on Ubuntu 24.04 (cgroup v2), Monitor Docker 1.20 with this change, ~60 containers, 60 s scan interval.

🤖 Generated with Claude Code

Memory usage is usage - inactive_file, like docker stats. On cgroup v2
active page cache stays in the figure, so containers that just read
large files show memory their processes don't hold. The new per-instance
option (default false) subtracts all file cache instead: 'file' on
cgroup v2, 'total_cache'/'cache' on cgroup v1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant