[PR #5504] [Engine] Credit clean active_file cache in the conversation memory guard #5483

Open
opened 2026-11-07 23:44:22 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5504
Author: @giphoo
Created: 11/7/2026
Status: 🔄 Open

Base: main ← Head: fix/active-file-cache-credit


📝 Commits (1)

  • 37bedf6 Credit clean active_file cache in the conversation memory guard

📊 Changes

1 file changed (+15 additions, -6 deletions)

View changed files

📝 src/core/conversation_memory.cpp (+15 -6)

📄 Description

Problem and result

The conversation memory guard refused session reads on an mmap-heavy engine because reclaimable_cache() only credited inactive_file, giving 0 reclaimable bytes even when 17+ GiB of clean file cache sat on the active LRU list.

After this change, both inactive_file and active_file are credited (less dirty and writeback, capped at the cgroup's current usage).

none

Approach

The current comment says active_file (it holds mlocked pages) - but on cgroup v2, mlocked pages are counted in unevictable, not active_file. Clean active_file pages are regular file cache on the active LRU list and are reclaimable by the kernel.

An mmap-heavy engine (model weights read through mappings) naturally keeps its file cache on the active list. Measured on a production system:

inactive_file: 0
active_file:   17.5 GiB
file_dirty:    0
unevictable:   0

The guard read 0 credit and refused a 50 MiB session file read with 28 GiB actually free.

This PR credits inactive_file + active_file, still less dirty and writeback, still capped at the cgroup's charged usage, and still does not credit shmem (the KV pool's pinned complements).

Validation

Passed (reference implementation, Linux, cgroup v2, mmap-heavy workload):

  • Session read admission succeeds when active_file holds the file cache
  • 51-request conversation rotation with 0 OOM after the change

Failed: none observed

Not run:

  • cgroup v1 (total_active_file path is added but untested)
  • Windows (no cgroup memory.stat)
  • CUDA, SYCL, Metal (host-side only)

Limits

  • Crediting active_file assumes the kernel can reclaim those pages under pressure. On a system with genuine memory shortage, reclaiming active file cache causes I/O to re-read the pages later, trading latency for admission.
  • cgroup v1 path added but 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/5504 **Author:** [@giphoo](https://github.com/giphoo) **Created:** 11/7/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/active-file-cache-credit` --- ### 📝 Commits (1) - [`37bedf6`](https://github.com/Niko1221/Strata/commit/37bedf6b59386eecc15f257d6e14900d3e6a26a5) Credit clean active_file cache in the conversation memory guard ### 📊 Changes **1 file changed** (+15 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/core/conversation_memory.cpp` (+15 -6) </details> ### 📄 Description ## Problem and result The conversation memory guard refused session reads on an mmap-heavy engine because `reclaimable_cache()` only credited `inactive_file`, giving 0 reclaimable bytes even when 17+ GiB of clean file cache sat on the active LRU list. After this change, both `inactive_file` and `active_file` are credited (less dirty and writeback, capped at the cgroup's current usage). ## Related discussion none ## Approach The current comment says `active_file (it holds mlocked pages)` - but on cgroup v2, mlocked pages are counted in `unevictable`, not `active_file`. Clean `active_file` pages are regular file cache on the active LRU list and are reclaimable by the kernel. An mmap-heavy engine (model weights read through mappings) naturally keeps its file cache on the active list. Measured on a production system: ``` inactive_file: 0 active_file: 17.5 GiB file_dirty: 0 unevictable: 0 ``` The guard read 0 credit and refused a 50 MiB session file read with 28 GiB actually free. This PR credits `inactive_file + active_file`, still less dirty and writeback, still capped at the cgroup's charged usage, and still does not credit shmem (the KV pool's pinned complements). ## Validation **Passed (reference implementation, Linux, cgroup v2, mmap-heavy workload):** - Session read admission succeeds when active_file holds the file cache - 51-request conversation rotation with 0 OOM after the change **Failed:** none observed **Not run:** - cgroup v1 (`total_active_file` path is added but untested) - Windows (no cgroup memory.stat) - CUDA, SYCL, Metal (host-side only) ## Limits - Crediting `active_file` assumes the kernel can reclaim those pages under pressure. On a system with genuine memory shortage, reclaiming active file cache causes I/O to re-read the pages later, trading latency for admission. - cgroup v1 path added but not tested. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#5483
No description provided.