feat(memory): add safe-point SessionBank budget governor - #357
feat(memory): add safe-point SessionBank budget governor#357PhilipJohnBasile wants to merge 2 commits into
Conversation
2382dfd to
8bc4d88
Compare
bc6f9bc to
4adb2fa
Compare
|
Thanks. The safe-point rule is the right property and I want it: touch the bank only after taking the model lock without blocking, and only when the foreground, scheduler, restore, commit, MTP and postcommit stages are all idle. The problem is that there is already a governor for the bank budget. It comes from the memory plan (plan-driven defaults, a dynamic ceiling with early pressure, a structured 507 when an out-of-memory is projected, SSD spill), plus the #447 and #450 admission work now in 2.11.2. Two controllers would fight over the same budget. So the plan is to fold your safe-point apply into that governor, with your name on it, rather than merge a second controller. On hold until then. Your synthetic measurement is useful either way as the ceiling on the overhead. |
|
@youssofal Agreed: the memory-plan governor should remain the single owner of the bank budget. Please fold the safe-point apply mechanism into that controller rather than introducing this as a competing governor. The invariant to preserve is nonblocking acquisition of the model lock, followed by rechecking that foreground, scheduler, restore, commit, MTP, and postcommit work are idle before any bank mutation. Sampling remains outside that lock. The existing synthetic receipt measures controller overhead only, not live pressure/OOM protection. I am leaving the branch held for your governor integration, with no second-controller changes. |
This extracts the SessionBank memory governor from #336 as one reviewable system.
It adds an opt-in controller behind
MTPLX_MEMORY_GOVERNOR=1. The controller samples process memory, applies hysteresis to SessionBank budget changes, and mutates the bank only after acquiring the model lock nonblocking and confirming that foreground, scheduler, restore, commit, MTP, and postcommit work are idle. Sampling happens before the lock is acquired.Measurement
Command:
python3 scripts/bench_memory_governor.py --observe-iterations 200000 --apply-iterations 50000 --batches 40 --output docs/benchmarks/sessionbank-memory-governor-no-model-20260826.jsonApple Silicon arm64, Python 3.14.7:
This is a synthetic controller-overhead measurement. It does not load a model, import MLX, or simulate a live macOS memory-pressure event. The tracked JSON receipt includes the exact command, host, configuration, and SHA-256 hashes of the measured inputs.
Validation
A full Ruff run without the exclusion still reports the existing
last_history_roleF841 inmtplx/server/openai.py; the same failure reproduces on untouched upstream/main.Excluded from this PR