Archived
kv tiers: a restore makes room the way pressure does, and a chain the pool cannot hold stops at a snapshot
A restore reserved only from the free list. The reserve's trim leaves a quarter of the pool free
after every publish, so a returning conversation larger than that came back as far as the free
list reached, and the lookup stopped at the first block still on the host. On GLM-5.3-Flash at
eight ranks, two conversations of 314K tokens in a 446,832-token pool: the second turn of the
first brought back exactly the 27,930 free blocks, hit 111,772 tokens, and on its hybrid state
resumed at the snapshot at 1,024, since geometric backoff keeps nothing between 1,024 and 131,072.
Its prefill took 84 s instead of under one.
PCBinding::restore_plan now makes room before the engine plans the restore, the same way
PCBinding::evict does for an admission: PrefixCache::trim_for drops entries whose host copy has
landed, the engine lands pending copies (flush_fn), and it drops again. It never erases one,
spares the restoring chain itself and every chain a waiting request holds, and like trim never
touches one a running sequence reads. The free quarter may go; the reserve's trim after the next
publish frees it again. One block table serves every rank, so the room rank 0's cache makes is
room on every rank, as with evict.
When the pool still cannot hold the chain, PrefixCache::restorable_from cuts it at the deepest
valid snapshot the shorter prefix reaches, so no block comes back past the point the hit resumes
from; without recurrent state it cuts where the room ends. TierExec::issue_restore keeps its own
cut as the backstop.
Both cuts are counted: radiance:prefix_restore_cuts_total for restores the pool could not hold
whole (/sessions moved.restore_cuts), and radiance:prefix_hit_cuts_total{reason="resumed_below"}
for admissions that resumed more than one checkpoint interval below their attention hit, which
hit_cut_tokens alone did not tell apart from many small tails (/stats and /sessions hit_cuts).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7d392b0400
commit
4be0a34791
16 files changed
+205
-39
No files matched your search
@@ -170,6 +170,8 @@ struct IPrefixCache {
|
||||
virtual CkptCounts ckpt_counts() const { return {}; }
|
||||
/* Entries expired by --prefix-cache-ttl; not counted as evictions. */
|
||||
virtual int64_t expired() const { return 0; }
|
||||
/* Restores the pool could not hold whole (PrefixCache::Stats::restore_cuts). */
|
||||
virtual int64_t restore_cuts() const { return 0; }
|
||||
virtual int64_t ckpt_expired() const { return 0; }
|
||||
|
||||
/* Tokens of context held only by the cache right now. Blocks a running sequence also reads
|
||||
@@ -346,6 +348,21 @@ struct PCBinding final : IPrefixCache {
|
||||
void restore(const Request& r) override {
|
||||
if (restore_fn) restore_fn(r);
|
||||
}
|
||||
/* The entries restore_fn brings back, in chain order: the whole chain if the pool can be made
|
||||
* to hold it, otherwise cut (PrefixCache::restorable_from). Room is made as evict() makes it,
|
||||
* dropping entries with a landed host copy, then landing pending copies and dropping those, but
|
||||
* never erasing one: a restore is worth no lost conversation. The pool's free quarter can go
|
||||
* to it; the reserve's trim after the next publish frees it again. */
|
||||
std::vector<BlockHash> restore_plan(const Request& r, uint64_t salt) {
|
||||
media_keys(r, &mm_, salt);
|
||||
std::vector<BlockHash> want = m->restorable_from(r.prompt, mm_);
|
||||
const int64_t need = (int64_t)want.size() - m->restore_room();
|
||||
if (need <= 0) return want;
|
||||
const int64_t k = m->trim_for(r.prompt, mm_, need);
|
||||
if (k < need && flush_fn && flush_fn()) (void)m->trim_for(r.prompt, mm_, need - k);
|
||||
/* Landing copies may have moved records; take the chain again against the room made. */
|
||||
return m->restorable_from(r.prompt, mm_, m->restore_room());
|
||||
}
|
||||
void begin_step() override { m->begin_step(); }
|
||||
void hold(const Request& r) override {
|
||||
media_keys(r, &mm_, salt_id);
|
||||
@@ -405,6 +422,7 @@ struct PCBinding final : IPrefixCache {
|
||||
return { st.ckpt_retired, st.ckpt_lru, st.ckpt_refused };
|
||||
}
|
||||
int64_t expired() const override { return m->stats().expired; }
|
||||
int64_t restore_cuts() const override { return m->stats().restore_cuts; }
|
||||
int64_t ckpt_expired() const override { return m->stats().ckpt_expired; }
|
||||
int64_t held_tokens() const override { return m->unshared_tokens(); }
|
||||
|
||||
|
||||
Reference in new issue
Block a user