File tier: decide unbuffered reads from the expert bytes it reads, again once the RAM copy is built (#577)

0.1.38 made the choice before the resident set existed, from the budget asked for, against every shard's bytes
(dense weights and the PLE table included). On a 96 GB PC with UD-Q4_K_XL (budget 72 GiB, 48.94 GiB really
resident) that read 83.0 - 72 - 4 = 7 GiB of room against 103.7 GiB of files, so every refill after a prompt read
the drive: prompts 15-40% slower than 0.1.34.

- platform::file_cache_keeps(avail, arena, read): the decision, unit-tested in platform_memory_test with the
  reporter's numbers and the 32/64 GB PCs of #357/#362.
- set_unbuffered: the arena is at most every expert's bytes, and the cache has to keep only the experts outside it.
- recheck_unbuffered, after pin_cache_complement: the same decision from the RAM the copy really holds and the
  expert bytes outside it; switches either way (startup, nothing reading) and logs the numbers.
- The 32 and 64 GB PCs still read unbuffered (the profile fill and the copy too, as before).

Same tokens either way: only how the same bytes are read changes.
This commit is contained in:
Niko1221 committed 2026-10-03 18:12:53 +02:00
1 parent 09817da397
commit d161e25ff6
7 files changed
+141 -15

No files matched your search

+10
View File
@@ -4082,6 +4082,16 @@ int main(int argc, char** argv) {
std::fprintf(stderr, "strata generate: CPU expert residency: %s\n", err.c_str());
return 1;
}
// #577: the unbuffered choice above was made before the RAM copy existed, from the budget asked for; now the
// copy is built, decide again from the RAM it really holds and the expert bytes outside it (on a 96 GB PC
// the file cache keeps those, and every refill after a prompt read the drive instead)
if (o.mmap_experts && o.resident_budget > 0) {
std::string why;
const bool was = src.unbuffered();
const bool ub = src.recheck_unbuffered(why);
std::fprintf(stderr, "strata generate: the file tier reads %s%s (%s)\n",
ub ? "unbuffered" : "through the file cache", ub == was ? "" : " (changed)", why.c_str());
}
}
if (o.serve) {
if (o.spec < 2 || o.mtp.empty() || o.prefill_chunk <= 0 ||