[PR #2501] [CLOSED] resident: fix budget clamp double-counting the pre-claimed arena #4080

Closed
opened 2026-11-07 15:33:04 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2501
Author: @G0-0000
Created: 10/14/2026
Status: ❌ Closed

Base: main ← Head: resident-clamp-claim-fix


📝 Commits (1)

  • 32100bf resident: fix budget clamp double-counting the pre-claimed arena

📊 Changes

1 file changed (+19 additions, -0 deletions)

View changed files

📝 src/core/expert_source.cpp (+19 -0)

📄 Description

Bug

With the NUMA pre-claim path (--numa-hot-node), reserve_resident_arena() faults the whole --resident-budget-gib arena into the cgroup's current before pin_cache_complement() reads available memory. The clamp (clamp_resident_budget) then charges the budget for its own arena — the same RAM counted once as "used" and again as "to allocate".

Measured on a Tesla V100-SXM2-32GB (UD-Q4_K_XL, 71.73 GiB of experts, 48.22 GiB RAM complement, cgroup MemoryMax 100 GiB, 125.76 GiB host):

--resident-budget-gib 49.00 exceeds available RAM
(47.40 GiB minus 4 GiB headroom and a 0.25 GiB margin): 42.75 GiB

42.75 < 48.22, so 5.08 GiB of experts stayed file-backed although the host had ~50 GiB free.

Fix

Add the not-yet-used claim back to the available-memory reading — the reading the clamp would have taken had it run before the claim. The credit is zero when no arena was claimed, so the non-arena path is byte-identical. A new log line prints the accounting (reading + claim = available − headroom − margin → granted).

Measured, after the fix

  • 49.00 GiB requested → 49.00 GiB granted; the 48.22 GiB complement is fully resident (0 experts file-backed)
  • from_files == 0 now holds, so --drop-file-cache fires at last (see #2243 — it was gated off in every partial-residency run)
  • post-load: file cache 4.75 GiB (was 43.2), cgroup current 59.1 GiB (was 88.9), load 52 s
  • no claim → zero credit → arithmetic unchanged (default path untouched)

Discussion (not in this PR)

Once the budget covers the whole complement, the file tier is never read at runtime, so its page cache is dead weight. We load with STRATA_UNBUFFERED_LOAD=1 (O_DIRECT), which removed the remaining ~43 GiB of load-time cache pollution for us. Arguably, unbuffered load should be the default when --resident-budget-gib covers the full complement — happy to follow up with a measured PR if you agree.

Dependency and validation

Depends on #2242: arena_preclaim_ is introduced there, so this PR cannot build standalone against main until #2242 merges. Please do not merge this PR first. The fix plus credit regression tests were integrated LOCALLY on #2242 head f2ab2310; CUDA sm_70 strata and file_expert_source_test built, and CPU-only test passed with active NUMA credit assertions. These tests are NOT YET in this PR branch; I will update it once #2242 merges. HIP/SYCL and GPU runtime not tested.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2501 **Author:** [@G0-0000](https://github.com/G0-0000) **Created:** 10/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `resident-clamp-claim-fix` --- ### 📝 Commits (1) - [`32100bf`](https://github.com/Niko1221/Strata/commit/32100bfc05e36dc9ddafb974df853c10e4b2d722) resident: fix budget clamp double-counting the pre-claimed arena ### 📊 Changes **1 file changed** (+19 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/core/expert_source.cpp` (+19 -0) </details> ### 📄 Description ## Bug With the NUMA pre-claim path (`--numa-hot-node`), `reserve_resident_arena()` faults the whole `--resident-budget-gib` arena into the cgroup's `current` **before** `pin_cache_complement()` reads available memory. The clamp (`clamp_resident_budget`) then charges the budget for its own arena — the same RAM counted once as "used" and again as "to allocate". Measured on a Tesla V100-SXM2-32GB (UD-Q4_K_XL, 71.73 GiB of experts, 48.22 GiB RAM complement, cgroup MemoryMax 100 GiB, 125.76 GiB host): ``` --resident-budget-gib 49.00 exceeds available RAM (47.40 GiB minus 4 GiB headroom and a 0.25 GiB margin): 42.75 GiB ``` 42.75 < 48.22, so 5.08 GiB of experts stayed file-backed although the host had ~50 GiB free. ## Fix Add the not-yet-used claim back to the available-memory reading — the reading the clamp would have taken had it run before the claim. The credit is zero when no arena was claimed, so the non-arena path is byte-identical. A new log line prints the accounting (`reading + claim = available − headroom − margin → granted`). ## Measured, after the fix - 49.00 GiB requested → 49.00 GiB granted; the 48.22 GiB complement is fully resident (0 experts file-backed) - from_files == 0 now holds, so `--drop-file-cache` fires at last (see #2243 — it was gated off in every partial-residency run) - post-load: file cache 4.75 GiB (was 43.2), cgroup current 59.1 GiB (was 88.9), load 52 s - no claim → zero credit → arithmetic unchanged (default path untouched) ## Discussion (not in this PR) Once the budget covers the whole complement, the file tier is never read at runtime, so its page cache is dead weight. We load with `STRATA_UNBUFFERED_LOAD=1` (O_DIRECT), which removed the remaining ~43 GiB of load-time cache pollution for us. Arguably, unbuffered load should be the default when `--resident-budget-gib` covers the full complement — happy to follow up with a measured PR if you agree. ## Dependency and validation Depends on #2242: arena_preclaim_ is introduced there, so this PR cannot build standalone against main until #2242 merges. Please do not merge this PR first. The fix plus credit regression tests were integrated LOCALLY on #2242 head f2ab2310; CUDA sm_70 strata and file_expert_source_test built, and CPU-only test passed with active NUMA credit assertions. These tests are NOT YET in this PR branch; I will update it once #2242 merges. HIP/SYCL and GPU runtime not tested. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:33:04 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4080
No description provided.