prefill: batched unbuffered expert reads in the stager; close the experts.bin view once reads are unbuffered

NTFS serves unbuffered reads of a mapped file one at a time (WD SN580: 2 MiB reads at QD32
2.35 GB/s mapped vs 3.57 GB/s unmapped). With the file tier unbuffered (--resident-budget-gib
or STRATA_UNBUFFERED_LOAD=1) the mapped view is only a fallback after startup, so it is closed
(STRATA_KEEP_MAPPING=1 keeps it). The prompt path's stager claims runs of consecutive jobs and
reads them with one read_direct batch (STRATA_STAGER_BATCH, default 8 for file-backed blobs).

RTX 5070 Ti, 32 GB RAM, IQ3_XXS, 47.6K prompt, --resident-budget-gib 18 --prefill auto:32768:
1260 -> 1370 tok/s (batch 8) -> 1669 tok/s (view closed).

Ported from #833 onto the rewritten main. Two fixes on the way: unmapped_ is declared on every
platform (mapped_blob reads it outside the Windows block, so Linux did not compile), and
copy_blobs asks resident_blob, which follows the exchange rotation (STRATA_EXCHANGE_ROTATE).
This commit is contained in:
adonizm authored and Niko1221 committed 2026-10-07 21:18:06 +02:00
1 parent d9621d1e23
commit 0b030b96fc
4 files changed
+127 -22

No files matched your search

+8
View File
@@ -6080,6 +6080,14 @@ int main(int argc, char** argv) {
#endif
}
if (o.adapt_async && !src.complement_ready()) adapt_async_off("the resident RAM mode is not running");
// pp-opt: with the file tier unbuffered, the mapped view of experts.bin is only a fallback from here on - and while
// it exists NTFS serves the unbuffered reads one at a time (drop_mapping). STRATA_KEEP_MAPPING=1 keeps it (A/B).
if (srcp == &src && src.unbuffered() && std::getenv("STRATA_KEEP_MAPPING") == nullptr) {
std::string why;
const bool dropped = src.drop_mapping(why);
std::fprintf(stderr, "strata generate: the mapped view of the experts %s (%s)\n",
dropped ? "is closed" : "stays open", why.c_str());
}
if (o.serve) {
if (o.spec < 2 || o.prefill_chunk <= 0 ||
(graph_hits && (thits.d_res == nullptr || host_res.empty()))) {