Elastic K/V: VMM access failures roll back, failed growth stops the engine, the trim maps one run

From an audit of this PR, each finding checked against the code:
- VmmRange: a run whose cuMemSetAccess failed stayed counted as mapped (a later map_range skipped it, so the chunks
  were never made accessible); it is unmapped and freed again (commit_run).
- a failed growth or trim could leave host_res, d_res and the slot range half-changed while serve went on to the
  next request; such a failure now stops the engine, as other CUDA failures do. The residency uploads are checked.
- the trim maps the chunks it takes back as one run (one cuMemSetAccess instead of one per 2 MiB chunk) and refills
  the slots with async copies and one sync instead of a blocking cudaMemcpy per expert.

IQ2_XS: the served scenario (grow at a request and mid-decode, trim and refill, regrow, a parked conversation's
restore) runs as before; vmm_test passes.
This commit is contained in:
sergiywith authored and Niko1221 committed 2026-10-05 19:57:35 +02:00
1 parent 9e3dbfe74a
commit 025bf3b2ef
3 files changed
+54 -21

No files matched your search

+6 -3
View File
@@ -44,6 +44,9 @@ public:
private:
bool map_one(int64_t i, VmmChunk h);
bool set_access(int64_t lo, int64_t hi);
/// Readable and writable [lo, hi) (all newly mapped); when that fails they are unmapped and freed again, so no
/// chunk counts as mapped without access.
bool commit_run(int64_t lo, int64_t hi);
unsigned long long base_ = 0;
std::vector<VmmChunk> h_; // per chunk: its physical chunk, 0 = unmapped
};
@@ -54,7 +57,7 @@ template <class Take> bool VmmRange::map_range(int64_t lo, int64_t hi, Take take
int64_t run = -1; // access is set once per run of newly mapped chunks (it costs as much as the map)
for (int64_t i = lo; i < hi; ++i) {
if (mapped(i)) {
if (run >= 0 && !set_access(run, i)) return false;
if (run >= 0 && !commit_run(run, i)) return false;
run = -1;
continue;
}
@@ -62,12 +65,12 @@ template <class Take> bool VmmRange::map_range(int64_t lo, int64_t hi, Take take
if (h == 0) h = vmm_chunk_new();
if (h == 0 || !map_one(i, h)) {
if (h != 0) vmm_chunk_free(h);
if (run >= 0) set_access(run, i);
if (run >= 0) commit_run(run, i);
return false;
}
if (run < 0) run = i;
}
return run < 0 || set_access(run, hi);
return run < 0 || commit_run(run, hi);
}
} // namespace strata::core