Skip to content

feat: replace fixed 80% RAM reserve with bounded-reserve formula#103

Merged
Andyyyy64 merged 4 commits into
Andyyyy64:mainfrom
samarthpatel24:bounded-ram-reserve
Jun 14, 2026
Merged

feat: replace fixed 80% RAM reserve with bounded-reserve formula#103
Andyyyy64 merged 4 commits into
Andyyyy64:mainfrom
samarthpatel24:bounded-ram-reserve

Conversation

@samarthpatel24

Copy link
Copy Markdown
Contributor

What

Replace the hardcoded total_ram * 0.80 heuristic with a bounded-reserve function: total - clamp(total * 0.15, 4 GiB, 32 GiB).

  • Add estimate_usable_ram(total: int) -> int to hardware/memory.py with inline constants
  • Update both call sites (compatibility checker + CLI auto min-params)
  • Add parameterized unit tests + update two existing shared-memory APU assertions
Total RAM Old (20% reserve) New (bounded)
16 GB 12.8 GB 12.0 GB
32 GB 25.6 GB 27.2 GB
64 GB 51.2 GB 54.4 GB
128 GB 102.4 GB 108.8 GB
1 TB 819.2 GB 992.0 GB

Why

The flat 20% reserve wastes too much on large machines (e.g. 200 GB reserved on a 1 TB box) and doesn't reserve enough on small ones. The bounded formula scales the reserve with machine size while capping it at 32 GiB.

Part 1 of #51

Testing

  • Tests pass (pytest) — 321 passed
  • New tests added — parameterized tests for 16 GB, 32 GB, 64 GB, 128 GB, 1 TB + boundary checks
  • Tested on real hardware — 15.3 GB RAM, RTX 4070 Laptop GPU, ranking works end-to-end

Notes

Part 2 (available-RAM awareness, --planning/--strict-now flags, dual fit tracking) will follow in a separate PR that closes #51.

@samarthpatel24

Copy link
Copy Markdown
Contributor Author

Add max(0, ...) guard to match the proposed signature in #51 — prevents negative return if total RAM is somehow below the 4 GiB minimum reserve.

@Andyyyy64 Andyyyy64 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed this locally. This is the right first step for #51: replace the fixed 80% RAM rule with a bounded reserve, while leaving current available RAM for the follow-up.

Minor note: estimate_usable_ram has the negative-return guard, but the tests do not cover a total RAM value below the 4 GiB minimum reserve. I do not think that needs to block this PR. The guard is simple, and the normal machine sizes are covered.

I am going to merge this, then answer the Part 2 questions on #51 separately.

@Andyyyy64 Andyyyy64 merged commit b6ca843 into Andyyyy64:main Jun 14, 2026
4 checks passed
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.

Make RAM fit checks distinguish planned capacity from current available memory

2 participants