mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2119] [CLOSED] Add disk-backed conversation cache parking (--conversation-cache-storage disk) #3872
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#3872
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/2119
Author: @dsovsyannikov
Created: 10/12/2026
Status: ❌ Closed
Base:
main← Head:conversation-disk-cache📝 Commits (1)
f961598Add disk-backed conversation cache parking (--conversation-cache-storage disk)📊 Changes
9 files changed (+964 additions, -15 deletions)
View changed files
📝
CMakeLists.txt(+5 -1)➕
include/strata/core/conversation_disk.hpp(+207 -0)📝
serve/server.py(+2 -1)➕
src/core/conversation_disk.cpp(+140 -0)➕
src/core/conversation_disk_test.cpp(+320 -0)📝
src/program/generate.cpp(+111 -9)➕
tools/conversation_cache_disk_measure.py(+152 -0)📝
tools/conversation_cache_parity.py(+16 -3)📝
tools/parking_test.py(+11 -1)📄 Description
Relation to parallel work
Two parallel efforts in the queue address disk parking; keeping this PR open as the minimal third option, with the differences called out:
--conversation-disk-persistsurvives restarts. Best when a RAM budget exists and only its overflow is the problem.ram|disk), not a spill target — a parked conversation holds zero resident RAM (measured −26 MiB vs +308 MiB held). Targets hosts where even the RAM parking budget does not fit beside the expert arena (admission there skips every conversation), or wherever you simply do not want parked state in RAM. Single +964/−15 commit; a parked conversation's bytes are identical to whatPOST /slots/0?action=savealready writes.Related: #2082 (admission fail-safety — the Windows commit-limit cases this PR's floor handling also dances around) and #2077 (
--prompt-cache-file, a complementary restart-persistence angle).Motivation
The conversation cache parks a switched-out conversation as a snapshot in host RAM, which keeps alternating chats (an agent controller plus subagents, for example) from re-reading their history. But on a machine whose RAM cannot hold the resident expert arena beside a parking budget, the admission check (
available_host_bytes()vs the snapshot estimate +--conversation-cache-min-free-mib) skips every conversation, so the feature is effectively unavailable there. This PR adds an opt-in disk backend: parked snapshots live on SSD and cost no resident RAM.What it adds
--conversation-cache-storage ram|disk(defaultram— current behaviour unchanged) and--conversation-cache-dir DIR. In disk mode--conversation-cache-mibis the disk budget.ConversationDiskCachereuses the session-file snapshot format with its validation and atomic publish (temp file + rename + flush), so a parked conversation is the same bytes aSAVEwrites. LRU eviction deletes the oldest file when the budget is exceeded.park()the snapshot costs no resident memory./metricsconversation_cachegains astoragefield; the Monitor tab reflects the mode.--layer-split(the session format has no stage images); retained-K/V reuse stays a ram-mode feature; restore speed depends on the page cache (42.5 ms hot in the measurement below, closer to the session-restore second when cold); a snapshot is tied to the engine version that wrote it (no tag gating — see #2098 for that machinery).Tests
conversation_disk_test(55 checks): park/restore byte-exact, LRU eviction, budget accounting, preflight refusal.tools/parking_test.pyandtools/conversation_cache_parity.pyaccept--storage disk; newtools/conversation_cache_disk_measure.pyreproduces the numbers below.7695859a.Measured (RTX 5090 Laptop 24 GB, IQ3_XXS pack, 14.4K-token conversation, 435 MiB snapshot)
Restoring the same conversation from disk after a full engine restart took 152 ms and the continuation was served from the restored state.
On the RAM-tight host this targets (resident arena leaves ~1.4–2.7 GiB free), ram mode skips parking entirely while disk mode keeps alternating conversations at ~2–4 s per switch instead of a full re-read of the history.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.