fix(ipc): rate-limit and contextualize high-memory warnings - #5962
Merged
Conversation
The "process memory usage is high" warning was emitted on every memory sample (~every 5s), so a process sitting above the warn threshold spammed the logs. The message also looked alarming and lacked the context needed to tell a process that started heavy from one whose usage grew over time. - Rate-limit the warning with a cooldown, re-emitting early only if usage grew significantly since the last warning (so real leaks still surface). - Reword the message and mark it advisory when no hard limit is configured (no process is terminated in that case). - Add diagnostic context: process uptime, whether a job is running, the post-prewarm baseline RSS, and growth since that baseline. - Add unit tests for the cooldown, growth re-emit, and logging context. Co-Authored-By: Claude <noreply@anthropic.com>
…nic clock The memory warning hardcoded "job process", but SupervisedProc is also the base for the inference process — it can't know which it is. Introduce an overridable `process_kind` property (base: "process", job executor: "job process", inference executor: "inference process") and use it in the memory log messages. Also switch process uptime and the warning cooldown from time.time() to time.monotonic(), so a wall-clock adjustment can't skew them. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
theomonnom
approved these changes
Jun 4, 2026
Replace the optional string `process_kind` with an abstract property returning
a `SupervisedProcKind` enum (`job`, `inference`). Subclassing `SupervisedProc`
now requires declaring a kind, which keeps the memory-warning log from ever
mislabelling a process (the previous string default was a footgun).
The enum overrides `__str__` so f-string interpolation renders as the bare
value ("job process …", "inference process …") on Python 3.10 — `StrEnum` is
3.11+ and the project still targets 3.10.
Test fakes (`_DummySupervisedProc`, `_FakeProc`) now declare a kind. Added a
test that verifies the enum stringifies cleanly and one that verifies a
subclass missing `process_kind` raises TypeError at instantiation.
Co-Authored-By: Claude <noreply@anthropic.com>
theomonnom
reviewed
Jun 4, 2026
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
_MEMORY_WARN_COOLDOWN(120s) per process, but re-emits early if usage grew by ≥_MEMORY_WARN_RESET_DELTA_MB(50MB) since the last warning, so real leaks still surface promptly.uptime,has_running_job,baseline_memory_mb,growth_memory_mb(current − baseline).process_kindproperty: base ="process", overridden to"job process"/"inference process".Behavior
memory_limit_mbpath is untouched except for richer log context. Warning thresholds and defaults unchanged.extrakeys changeTesting
tests/test_supervised_proc_memory.py): cooldown suppression, growth-based re-emit, baseline/growth reporting, defaultprocess_kind.