[PR #699] [CLOSED] Linux: read ahead at startup (cold start ~920 s → 70 s) #2772

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/699
Author: @jesdga95
Created: 10/3/2026
Status: ❌ Closed

Base: main ← Head: linux-load-read-ahead


📝 Commits (2)

  • 0173fc4 Linux: read ahead of the mapped loads at start
  • 5949e9d Linux: read ahead of the head, embedding and vision encoder loads; time them

📊 Changes

12 files changed (+174 additions, -16 deletions)

View changed files

📝 docs/DETAILS.md (+6 -0)
📝 include/strata/core/expert_source.hpp (+7 -0)
📝 include/strata/platform/memory.hpp (+8 -0)
📝 src/core/expert_source.cpp (+31 -3)
📝 src/core/mtp.cpp (+7 -0)
📝 src/core/native_dense.cpp (+5 -0)
📝 src/core/native_head.cpp (+3 -0)
📝 src/core/peer_experts.cpp (+6 -1)
📝 src/core/weights.cpp (+7 -0)
📝 src/platform/memory.cpp (+33 -0)
📝 src/program/generate.cpp (+38 -11)
📝 tools/vision/strata_vision.cpp (+23 -1)

📄 Description

On Linux every startup read went to the drive one ~128 KB request at a time (page faults through the mmap, or plain freads with the default readahead), so a cold start sat at queue depth ~2 for about fifteen minutes. Most of it was "filling the GPU's expert cache" at 30-39 MB/s from an NVMe that does ~3 GB/s with a deep queue. Windows already has an unbuffered, overlapped read path for this (set_unbuffered / read_direct); on Linux set_unbuffered returns false, so these reads went through the page cache one fault at a time.

This asks the kernel for the pages ahead of each read (madvise / posix_fadvise WILLNEED, in 128 KiB steps because WILLNEED only reads one readahead window per call) for the weights, the native dense matrices, the profile fill (256 pairs ahead), the peer tier's fill (--peer-device), the resident RAM copy, the MTP draft files, the native output head and token embedding, and strata-vision's projector. STRATA_READ_AHEAD=0 turns it all off, and each phase now logs how long it took.

Ryzen 9 9950X, RTX 5090, 32 GB DDR5, Gen3 NVMe, Ubuntu (kernel 7.0), v0.1.38, cold page cache:

  • Q2_0 resident, 262K: ready in 70 s, was ~920 s. The fill went from ~39 MB/s to 3.2 GB/s (21.47 GiB in 7.1 s).
  • IQ3_XXS resident + vision + peer tier (5060 Ti): ready in 32 s. MTP draft files 47 s → 0.3 s, peer fill 13.5 GiB in 5 s, 21.9 GiB RAM copy in 8 s, head/embedding/projector under a second each.
  • Decode unchanged: struct still gives the same 7,230 tokens, and the bench is within noise.

Only tested on Linux with CUDA. On Windows the new helper is a no-op (the unbuffered path covers it), and I haven't compiled it on Windows or HIP. With a layer split, the first card's fill gets the read-ahead (q8atnight measured it below); the other cards' fills don't yet.


🔄 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/699 **Author:** [@jesdga95](https://github.com/jesdga95) **Created:** 10/3/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `linux-load-read-ahead` --- ### 📝 Commits (2) - [`0173fc4`](https://github.com/Niko1221/Strata/commit/0173fc46ce5b4225a71dc07e3a16a71102fc3646) Linux: read ahead of the mapped loads at start - [`5949e9d`](https://github.com/Niko1221/Strata/commit/5949e9d2fd3e114808edaccd0333ca6c063cf700) Linux: read ahead of the head, embedding and vision encoder loads; time them ### 📊 Changes **12 files changed** (+174 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+6 -0) 📝 `include/strata/core/expert_source.hpp` (+7 -0) 📝 `include/strata/platform/memory.hpp` (+8 -0) 📝 `src/core/expert_source.cpp` (+31 -3) 📝 `src/core/mtp.cpp` (+7 -0) 📝 `src/core/native_dense.cpp` (+5 -0) 📝 `src/core/native_head.cpp` (+3 -0) 📝 `src/core/peer_experts.cpp` (+6 -1) 📝 `src/core/weights.cpp` (+7 -0) 📝 `src/platform/memory.cpp` (+33 -0) 📝 `src/program/generate.cpp` (+38 -11) 📝 `tools/vision/strata_vision.cpp` (+23 -1) </details> ### 📄 Description On Linux every startup read went to the drive one ~128 KB request at a time (page faults through the mmap, or plain freads with the default readahead), so a cold start sat at queue depth ~2 for about fifteen minutes. Most of it was "filling the GPU's expert cache" at 30-39 MB/s from an NVMe that does ~3 GB/s with a deep queue. Windows already has an unbuffered, overlapped read path for this (`set_unbuffered` / `read_direct`); on Linux `set_unbuffered` returns false, so these reads went through the page cache one fault at a time. This asks the kernel for the pages ahead of each read (madvise / posix_fadvise WILLNEED, in 128 KiB steps because WILLNEED only reads one readahead window per call) for the weights, the native dense matrices, the profile fill (256 pairs ahead), the peer tier's fill (`--peer-device`), the resident RAM copy, the MTP draft files, the native output head and token embedding, and strata-vision's projector. `STRATA_READ_AHEAD=0` turns it all off, and each phase now logs how long it took. Ryzen 9 9950X, RTX 5090, 32 GB DDR5, Gen3 NVMe, Ubuntu (kernel 7.0), v0.1.38, cold page cache: - Q2_0 resident, 262K: ready in **70 s, was ~920 s**. The fill went from ~39 MB/s to 3.2 GB/s (21.47 GiB in 7.1 s). - IQ3_XXS resident + vision + peer tier (5060 Ti): ready in **32 s**. MTP draft files 47 s → 0.3 s, peer fill 13.5 GiB in 5 s, 21.9 GiB RAM copy in 8 s, head/embedding/projector under a second each. - Decode unchanged: struct still gives the same 7,230 tokens, and the bench is within noise. Only tested on Linux with CUDA. On Windows the new helper is a no-op (the unbuffered path covers it), and I haven't compiled it on Windows or HIP. With a layer split, the first card's fill gets the read-ahead (q8atnight measured it below); the other cards' fills don't yet. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:03:00 +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#2772
No description provided.