mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #773] [CLOSED] file tier: unbuffered reads on Linux too (O_DIRECT + the kernel's asynchronous reads) #2821
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2821
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/773
Author: @cakescats
Created: 10/4/2026
Status: ❌ Closed
Base:
main← Head:linux-direct-io📝 Commits (2)
637ce97file tier: unbuffered reads on Linux too (O_DIRECT + the kernel's asynchronous reads)2bdcf37file tier: STRATA_UNBUFFERED_LOAD=1 is not honoured without a RAM budget📊 Changes
4 files changed (+311 additions, -20 deletions)
View changed files
📝
include/strata/core/expert_source.hpp(+8 -4)📝
src/core/expert_source.cpp(+217 -10)📝
src/program/generate.cpp(+11 -4)📝
tests/core/file_expert_source_test.cpp(+75 -2)📄 Description
#286's unbuffered file tier exists on Windows only. On Linux the experts outside the RAM copy are always read through the page cache, as page faults of the mapped GGUF: small requests on the critical path, and pages that a 32 GB PC cannot keep beside a 16 GiB RAM copy anyway, so the same experts are read from the drive again and again.
This adds the Linux side of the same mechanism.
open_directopens the files withO_DIRECT.read_directqueues every 4 KiB-aligned window of a batch with oneio_submitand waits for all of them. That is the kernel's own asynchronous read (linux/aio_abi.h): no library, and Docker's default seccomp profile allows it, unlike io_uring. Each thread has its own context and aligned buffer, so concurrent batches never see each other's completions. Windows merges windows up to 1 MiB apart because of NTFS; here only windows that touch are merged. A refused submit or a failed read falls back to the mapping, as on Windows.The decision is Windows'
cache_counts = falsearm: unbuffered when the file cache could not keep the expert bytes outside the RAM copy (platform::file_cache_keeps, from MemAvailable and the tightest cgroup limit viahost_available_memory). It is re-checked once the copy is built (#577), andSTRATA_UNBUFFERED_LOAD=1/0forces it either way. A machine whose RAM can cache those bytes keeps the buffered path. A pack'sexperts.binworks too: its Linux open now records the path.direct_fallbacks()counts the blobs an unbuffered read could not deliver.The Windows code paths are unchanged; I had no Windows machine to build on. The new
#elif defined(__linux__)branches sit beside them.Measured. RTX 3080 Ti Laptop 16 GB, i9-12900H, 30 GB RAM, KIOXIA PCIe 4 NVMe, Linux 7.0, ext4. Setup:
--native),--resident-budget-gib 16,--expert-cache auto, 8K context, greedy.STRATA_UNBUFFERED_LOAD=0) against unbuffered, with the same binary.Tests.
file_expert_source_testgainstest_unbuffered_reads. It writes a synthetic pack of random bytes and reads it unbuffered three ways: one blob at a time, a batch of adjacent experts, andcopy_blob. It requires the file's bytes anddirect_fallbacks() == 0. A mutation that fails every read is caught. The pack is written in the working directory, not/tmp, so a file system withoutO_DIRECTskips the test with a message instead of failing it.ctest: 63 of 66 pass. The other three fail on this machine before and after the change, for these reasons:ple_parityneeds the Q2_0 pack;platform_memory_testneeds a higherulimit -l;expert_multi_testneeds AVX-512.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.