Skip to content

fix(memstats): Leave reclaimable page cache out of the OOM warning - #963

Merged
brawer merged 1 commit into
mainfrom
fix/oom-warning-reclaimable
Nov 16, 2026
Merged

brawer merged 1 commit into
mainfrom
fix/oom-warning-reclaimable

Conversation

@brawer

@brawer brawer commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Requested by Sascha · project thread

The "memory usage at N% of the cgroup limit -- at risk of being OOM-killed" warning compared memory.current with memory.max. That figure includes the page cache, which the mmap'd tables and the input downloads keep at the limit by design, so the warning fired on nearly every step. In the 2026-11-15 production run (logs/osmdiffs-weekly-rerun-20261115.log) it fired 21 times. The first one came in fetch_inputs, with 3 MB of anonymous memory, and rss_anon_bytes never went above 0.14 GB. docs/PRODUCTION.md already told readers to ignore the warning.

Changes

  • MemStats now also reads file and shmem from the cgroup's memory.stat, as cgroup_file_bytes and cgroup_shmem_bytes, and every step snapshot logs them.
  • New MemStats::cgroup_unreclaimable_fraction: usage minus the page cache the kernel can drop (file − shmem), divided by the limit. shmem still counts, so a workdir on tmpfs still warns. Without memory.stat, it falls back to the whole usage.
  • The 85% warning uses that fraction. It still logs cgroup_usage_fraction next to it.
  • scripts/test-on-hetzner/validate.py reports the new fraction when a record has it.
  • docs/PRODUCTION.md gets a note on the change.

Testing

  • New unit tests for memory.stat parsing and for the new fraction: page cache, shmem, no memory.stat, zero limit. cargo test --lib passes (457), and so does clippy.
  • tests/integration_test.rs fails here both with and without this change, because this machine has no tippecanoe. CI has it.

Generated by Claude Code

The 85% warning compared memory.current with memory.max. That counts the
page cache, which the pipeline's mmap'd tables and downloads keep at the
limit by design. So the 2026-11-15 production run warned 21 times,
starting in fetch_inputs with 3 MB of anonymous memory, while anonymous
RSS never went above 0.14 GB.

The warning now leaves out the page cache the kernel can drop: `file`
minus `shmem` from memory.stat. shmem still counts, so a workdir that
landed on tmpfs still warns. Without memory.stat, it falls back to the
whole usage. Both numbers are now logged with every snapshot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ttfb2JuvbLtNhvRsMwuK9e
@brawer brawer self-assigned this Nov 16, 2026
@github-actions github-actions Bot added the bug Something isn't working label Nov 16, 2026
@brawer
brawer merged commit b216073 into main Nov 16, 2026
7 checks passed
@brawer
brawer deleted the fix/oom-warning-reclaimable branch November 16, 2026 00:18

brawer commented Nov 21, 2026

Copy link
Copy Markdown
Owner Author

Verified in production. osmdiffs-internal/logs/osmdiffs-weekly-rerun-20261120.log (v0.8.19) has no "at risk of being OOM-killed" warning, while osmdiffs-weekly-rerun-20261115.log (v0.8.17) had it on almost every step. In the 2026-11-20 run, the cgroup peak reached its 8.59 GB limit (cgroup_peak_bytes 8,595,259,392), but that was page cache. Across the 62 snapshots, cgroup_current_bytes − cgroup_file_bytes + cgroup_shmem_bytes stayed at or below 0.43 GB, and rss_anon_bytes at or below 0.16 GB. So the warning stays quiet when it should, and cgroup_file_bytes and cgroup_shmem_bytes show up in every snapshot.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants