Files
Strata/include/strata/core/expert_cache_refuse.hpp
T
Niko1221 388a1554f0 expert cache: evict the slots a part-way shrink lost
With --vram-elastic, a VRAM command shrinks the expert cache by giving its
last segments back to the driver. When the driver refused a segment part way,
the segments released before the refusal were already gone, but the command
returned its error before the residency table was updated. The engine kept
serving with experts still listed in slots that were no longer mapped, and the
prompt path's loan could still sit past the end of the live slots.

Now the residency entries past what stays mapped are evicted after every
shrink, refused or not, the table is uploaded again and the loan moves down
to the end of the slots left; then the error goes out as before.

Also: when the unmap of a segment succeeded and only the release of its
handle failed, the segment was still counted as mapped. It now counts as
unmapped at once; the handle stays and is released again by the next grow
or at close.

The eviction is a pure function (strata/core/residency_trim.hpp) with its own
CPU test. expert_cache_segmented_test refuses an unmap and a release part way
through a shrink, through a test-only hook that the engine never sets
(strata/core/expert_cache_refuse.hpp), and checks the slots kept, the entries
evicted and a full grow afterwards. A shrink the driver accepts behaves as
before.
2026-11-14 04:49:38 +01:00

15 lines
671 B
C++

#pragma once
// Tests only: make one of the segmented expert cache's driver calls fail on purpose, so a test can check what a shrink
// that the driver refused part way leaves behind (src/core/expert_cache.cpp). The engine never sets it.
#include <cstdint>
namespace strata::core::ec_test {
/// Asked before each unmap and each release a shrink makes (`call` is "unmap" or "release", `seg` the segment's index).
/// True: that call counts as refused by the driver and is not made. Null (the default, and always in the engine): every
/// call is made as usual.
extern bool (*refuse_segment_call)(const char* call, int64_t seg);
} // namespace strata::core::ec_test