Tier RAM budget by host size#752
Conversation
Use 25% of physical RAM on hosts with 16GB or less, 35% on 32GB or less, and 50% above. Expose cbm_mem_ram_fraction_for_total() for unit tests and call it from MCP/CLI startup instead of a fixed 50% fraction. Signed-off-by: Andy11-cpu <canada11@duck.com>
|
Thanks for the RAM-budget split. Triage: high-priority stability/performance work from the memory-pressure track. Review will check that the tiered default is conservative on 16GB machines, does not regress larger-host throughput unexpectedly, and composes correctly with explicit memory-budget overrides. Please keep any benchmark or before/after memory observations in the PR description as it evolves. |
|
Quick status note: this PR is one of four open memory/RAM-policy changes (#833, #752, #586, #685) that we've reviewed individually and found genuinely complementary — so rather than merging them piecemeal, we're doing a combined design pass over the whole memory policy (explicit override, host-tiered defaults, retention bounds, post-index release, and the Windows auto-sync driver in #841) and will respond here with a concrete direction shortly. Your work is very much part of that plan — thanks for your patience! |
|
Thank you — this is a clean, well-judged fix: tiering the RAM fraction by host size (25% ≤16GB / 35% ≤32GB / 50% above) so small and containerized hosts don't over-commit, and it correctly reads the cgroup-aware total so a memory-limited container gets the right tier. Atomic, green on all platforms, with genuine boundary tests. Merged as a960d3d. It composes cleanly with the CBM_MEM_BUDGET_MB explicit override (override still wins) and the retention layer's re-read fallback covers the smaller-budget case with no lost edges. Appreciated — and thanks for splitting this out from the earlier bundle so it could land on its own merits! |
…ts, blinding backpressure) Distilled from DeusData#776's 132460f. This project sets arena_eager_commit=0 + purge_decommits=1 + purge_delay=0 in cbm_mem_init to reduce upfront memory, so mimalloc's committed-page counter reads low. On Linux mi_process_info() never sets current_rss (vendored/mimalloc/src/prim/unix/prim.c only fills peak_rss), so current_rss defaults to that low committed counter — cbm_mem_rss() returned a few MB while true RSS was multiple GB, leaving cbm_mem_over_budget() backpressure, the memory ceiling, and the host RAM tier blind on Linux. Prefer os_rss() (/proc/self/statm) as the primary source on Linux; macOS and Windows are unchanged (their mi_process_info current_rss is accurate via task_info / GetProcessMemoryInfo). cbm_mem_peak_rss() is untouched. Complements DeusData#752 by making the RAM tiers actually bite on Linux. Reproduce-first: mem_rss_reflects_external_resident_memory pins mimalloc's committed counter low with a live mi_malloc, then grows true RSS via a raw 256MB mmap (invisible to mimalloc); unfixed Linux returns the ~few-MB committed counter (RED), fixed Linux returns /proc RSS (GREEN). macOS/Windows pass either way, so the RED manifests on the Linux CI leg. Co-authored-by: petercoxphoto <info@petercox.ie> Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Summary
cbm_mem_ram_fraction_for_total()with unit testsMotivation
Split from #625 — reduces default memory reservation on 16GB machines without changing indexing behavior.
Test plan
mem_ram_fraction_*tier tests intest_mem.cmake -f Makefile.cbm test(CI)Signed-off-by: Andy11-cpu canada11@duck.com