mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1271] [CLOSED] serve: --conversation-cache-spill-dir keeps evicted conversations on disk across restarts #3349
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#3349
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/1271
Author: @ANBAL534
Created: 10/6/2026
Status: ❌ Closed
Base:
main← Head:conversation-spill-disk📝 Commits (8)
34e2409serve: keep evicted conversations on disk across restarts0d846c1Merge remote-tracking branch 'upstream/main' into conversation-spill-disk1904b8aserve: recompute the RAM conversation match after a failed disk attempt: make_room may have evicted the entry the stale index named1a9e8b9Merge remote-tracking branch 'upstream/main' into conversation-spill-disk4af468fMerge remote-tracking branch 'upstream/main' into conversation-spill-disk3d39c5fMerge branch 'main' into conversation-spill-diskc7d3bb6Merge branch 'main' into conversation-spill-disk3409b46conversation spill: the scan removes the writer's abandoned hidden temp📊 Changes
7 files changed (+992 additions, -25 deletions)
View changed files
📝
CMakeLists.txt(+4 -1)📝
docs/DETAILS.md(+29 -0)📝
include/strata/core/conversation_cache.hpp(+131 -15)➕
include/strata/core/conversation_spill.hpp(+94 -0)➕
src/core/conversation_spill.cpp(+342 -0)➕
src/core/conversation_spill_test.cpp(+207 -0)📝
src/program/generate.cpp(+185 -9)📄 Description
The RAM conversation cache (
--conversation-cache-mib) parks whole conversations so a later request reuses their prefill instead of reading the prompt again. But a parked conversation is dropped the moment RAM pressure or--conversation-cache-slotsevicts it, and every parked conversation is gone when the engine restarts. On a small-RAM PC the budget is tight, so the conversations that matter are the ones evicted; after a restart the long prompt is read again from token 0.--conversation-cache-spill-dir DIRkeeps what the RAM cache evicts: the evicted conversation is written to DIR as an ordinary session file (the same format and model/config identity as the slot save/restore API) plus a small metadata sidecar, so a later request - or a restart - reads it back instead of re-reading the prompt.TL;DR
What changes
make_room) is handed to a spill callback that writes it to the directory; on a cleanQUITor stdin close the parked conversations spill before exit (spill_all).--conversation-cache-min-free-mibfloor.--conversation-cache-similarity Fand--conversation-cache-n-min Nfilter weak matches (least common-prefix fraction / token count); both default to 0, which keeps every exact prefix the RAM cache would have used.conversation_file.cpprather than adding a second on-disk format: a spilled conversation is byte-for-byte what the slot save/restore API would write, so the two are interchangeable and there is one format, one model/config identity rule, one checksum.Why it helps
--conversation-cache-miband let the disk tier hold the rest: the RAM cache stays a small hot working set, and the conversations it evicts stay resumable on NVMe instead of being recomputed. On a 12-16 GB card where the cache budget competes with the expert cache, this trades a little disk for prompt-read time.spill dir ready (N conversations, ...)at start, and the first request after a restart resumes from disk instead of reading the whole prompt again.Flags
--conversation-cache-spill-dir DIR--conversation-cache-disk-mib N--conversation-cache-similarity F--conversation-cache-n-min NTesting
conversation_spill_test(41 checks, wired intoSTRATA_BUILD_CONVERSATION_TESTS): spill/match/load round-trip with the K/V compared byte for byte, similarity and n_min filtering, refusal of a foreign model/config identity, disk-budget eviction, reindex on reopen, and the RAM cache handing its evictions to the tier (make_roomcallback +spill_all).generate.cppand the module compile in the CUDA build andstratalinks; the flags appear in--helpand bad values are refused.Scope
Single-GPU only: with
--layer-splitthe disk tier stays off, matching the existing parking limit. A disk hit is read into host RAM before restore, so it must fit the RAM cache budget and leave the min-free floor available, or the request reads the prompt normally.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.