[PR #4258] [Engine] --drop-file-cache: hand the model files' page cache back once the startup reads are done #4976

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4258
Author: @G0-0000
Created: 10/26/2026
Status: 🔄 Open

Base: main ← Head: feat/drop-file-cache-20261027


📝 Commits (1)

  • e09a687 generate: --drop-file-cache hands the model files' page cache back after the startup reads

📊 Changes

4 files changed (+131 additions, -1 deletions)

View changed files

📝 docs/DETAILS.md (+7 -0)
📝 include/strata/core/expert_source.hpp (+8 -0)
📝 src/core/expert_source.cpp (+64 -0)
📝 src/program/generate.cpp (+52 -1)

📄 Description

Problem

A resident engine maps the model files and reads them once at startup. By the time those reads are done every expert is in VRAM or in the RAM copy, but the kernel still holds the mapped model files' page cache: a third copy of the same bytes (about 55 GiB on a 48-layer pack), and the one copy the kernel cannot take back cheaply while this process maps the files. On a host whose RAM is mostly the model, that copy is what makes it page under load.

Change

--drop-file-cache (off by default, Linux only). Four files:

  • FileExpertSource::drop_file_cache(std::string&) - madvise(MADV_DONTNEED) over each mapped view, then posix_fadvise(POSIX_FADV_DONTNEED) on that file. One call alone releases nothing: a mapped page is skipped by fadvise, an unmapped clean page stays on the LRU. Measured here: the pair took all 512 MiB of a probe file (mincore back to 0); either call alone took none.
  • generate.cpp - the option, its help text, and one call after the startup reads finish and before serving, with a log line that says how many bytes were advised.
  • The drop is refused when any expert still reads from the files (a layer split, or a complement not held in RAM): there the page cache is the tier that serves those reads. The log says which case applied.
  • docs/DETAILS.md - one paragraph next to the file-tier section.

Off is byte-identical to before: no code path changes unless the flag is given.

Relation to earlier work

  • Supersedes #2243, closed by the 0.2.0-beta tracker reset; this is the same feature redone on v0.2.6.
  • The same two calls already exist inside the engine for #1250, where a page-locked complement needs the room. This PR only asks for them by name after startup and leaves the #1250 path untouched.

Validation

  • Build: CUDA 12.9, CMAKE_CUDA_ARCHITECTURES=70, engine target.

  • Host tests: ctest --test-dir build-dropcache -R "expert_source|cache|file" on this host: 9 tests, all 9 passed (file_expert_source_test, expert_profile_save_test, expert_profile_version_test, expert_cache_per_layer_test, expert_cache_segmented_test, expert_cache_slot_guard_test, uma_cache_test, conv_cache_test, direct_file_async_test).

  • Hardware run, this same build, on a V100-32GB host (Linux), 2026-10-27: started with the expert complement resident and the flag on. The engine printed

    strata generate: --drop-file-cache: 103.68 GiB of the model files' pages advised back to the kernel in 7244 ms
    

    and /proc/meminfo Cached fell from 77.2 GiB to 11.2 GiB at that point; the difference between advised and reclaimed is shared and dirty pages, as the message says. No request was served in that run. The host was returned to its production configuration afterwards and answered 200.

  • Caveat: that run was not under the host's usual systemd NUMA binding, so the complement was not page-locked on the GPU's node. The drop itself is node-agnostic, but the RAM placement differed from a normal production start.

Limits

  • Linux only. Windows hands a VRAM expert's pages back per expert already (STRATA_FILE_RELEASE) and has no equivalent here.
  • Not tested: non-Linux, a layer split with experts in the files (the refusal path), hosts whose complement does not fit in RAM, a second advise path after a long conversation.

🔄 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/4258 **Author:** [@G0-0000](https://github.com/G0-0000) **Created:** 10/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/drop-file-cache-20261027` --- ### 📝 Commits (1) - [`e09a687`](https://github.com/Niko1221/Strata/commit/e09a687a986f97eeef718f32461ca03d6dd06d36) generate: --drop-file-cache hands the model files' page cache back after the startup reads ### 📊 Changes **4 files changed** (+131 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+7 -0) 📝 `include/strata/core/expert_source.hpp` (+8 -0) 📝 `src/core/expert_source.cpp` (+64 -0) 📝 `src/program/generate.cpp` (+52 -1) </details> ### 📄 Description ## Problem A resident engine maps the model files and reads them once at startup. By the time those reads are done every expert is in VRAM or in the RAM copy, but the kernel still holds the mapped model files' page cache: a third copy of the same bytes (about 55 GiB on a 48-layer pack), and the one copy the kernel cannot take back cheaply while this process maps the files. On a host whose RAM is mostly the model, that copy is what makes it page under load. ## Change `--drop-file-cache` (off by default, Linux only). Four files: - `FileExpertSource::drop_file_cache(std::string&)` - `madvise(MADV_DONTNEED)` over each mapped view, then `posix_fadvise(POSIX_FADV_DONTNEED)` on that file. One call alone releases nothing: a mapped page is skipped by fadvise, an unmapped clean page stays on the LRU. Measured here: the pair took all 512 MiB of a probe file (mincore back to 0); either call alone took none. - `generate.cpp` - the option, its help text, and one call after the startup reads finish and before serving, with a log line that says how many bytes were advised. - The drop is refused when any expert still reads from the files (a layer split, or a complement not held in RAM): there the page cache is the tier that serves those reads. The log says which case applied. - `docs/DETAILS.md` - one paragraph next to the file-tier section. Off is byte-identical to before: no code path changes unless the flag is given. ## Relation to earlier work - Supersedes #2243, closed by the 0.2.0-beta tracker reset; this is the same feature redone on v0.2.6. - The same two calls already exist inside the engine for #1250, where a page-locked complement needs the room. This PR only asks for them by name after startup and leaves the #1250 path untouched. ## Validation - Build: CUDA 12.9, `CMAKE_CUDA_ARCHITECTURES=70`, engine target. - Host tests: `ctest --test-dir build-dropcache -R "expert_source|cache|file"` on this host: 9 tests, all 9 passed (file_expert_source_test, expert_profile_save_test, expert_profile_version_test, expert_cache_per_layer_test, expert_cache_segmented_test, expert_cache_slot_guard_test, uma_cache_test, conv_cache_test, direct_file_async_test). - Hardware run, this same build, on a V100-32GB host (Linux), 2026-10-27: started with the expert complement resident and the flag on. The engine printed strata generate: --drop-file-cache: 103.68 GiB of the model files' pages advised back to the kernel in 7244 ms and `/proc/meminfo` Cached fell from 77.2 GiB to 11.2 GiB at that point; the difference between advised and reclaimed is shared and dirty pages, as the message says. No request was served in that run. The host was returned to its production configuration afterwards and answered 200. - Caveat: that run was not under the host's usual systemd NUMA binding, so the complement was not page-locked on the GPU's node. The drop itself is node-agnostic, but the RAM placement differed from a normal production start. ## Limits - Linux only. Windows hands a VRAM expert's pages back per expert already (`STRATA_FILE_RELEASE`) and has no equivalent here. - Not tested: non-Linux, a layer split with experts in the files (the refusal path), hosts whose complement does not fit in RAM, a second advise path after a long conversation. --- <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#4976
No description provided.