mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 21:05:40 +07:00
[PR #5399] Serve: parked conversations spill to a disk tier instead of being dropped #5415
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#5415
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/5399
Author: @nrtdadmin
Created: 11/6/2026
Status: 🔄 Open
Base:
main← Head:f-0210-conv-disk-cache📝 Commits (2)
d272ca9Serve: parked conversations spill to a disk tier instead of being dropped. The parked cache only had RAM: once the --conversation-cache-mib budget or the slot count filled, evict_oldest dropped the oldest conversation and its next request re-read the whole prompt. With --conversation-cache-file-mib > 0 (--conversation-cache-file-dir, default /conv-cache) eviction now writes the heavy parts (K/V pages, running state, checkpoint copies) to /.conv and keeps a RAM shell (ids, images, pinned) so best() still finds it; a returning conversation is read whole back from disk and the file goes. A shell still holds its slot - the count bounds RAM and disk entries together - and leaves for good when it is the oldest and a slot is needed or the disk budget ran out; borrows() refuses a spilled entry, the restore is all-or-nothing, so a half-borrowed K/V never reaches the graph. Enabling the tier wipes the folder: a spill file belongs to the engine that wrote it and a restart starts the cache empty. The serve web monitor gets a "Their storage (disk)" row under "Their memory (RAM)" (server.py counts the folder next to the INFO line, app.js renders usage and spills). Test: conversation_cache_disk_test round-trips a 751 MiB synthetic image (100k tokens, 5 K/V pages, 3 checkpoints, 2 stage images, a buffer crossing the 16 MiB segment edge), byte-identical, refuses a truncated file without crashing, and survives an empty image; live check on a 4-GPU --serve box.f027b79Serve: budget pressure spills RAM entries before it kills a shell. The eviction loop took the oldest entry whatever it was: with a spilled shell at the head (the common shape once the tier starts working) a conversation returning after the first spill erased its file and left the loop still short of RAM, so every park killed the shell the previous park had just written - the folder held at most one file however much pressure the RAM budget was under, which is the opposite of why the tier exists. The loop body now spills the oldest entry still holding K/V and frees a shell only when nothing else can free RAM (or a slot is needed for a new park, as before). Test: on the 4-GPU box with the RAM cache dialed to 2 GiB and cold conversations arriving one at a time, spilled files now pile up in the folder and a returning conversation reads its K/V back whole and removes the file; before the fix the folder stayed at one file under the same pressure.📊 Changes
8 files changed (+437 additions, -3 deletions)
View changed files
📝
CMakeLists.txt(+7 -1)📝
include/strata/core/conversation_cache.hpp(+106 -1)📝
serve/server.py(+34 -0)📝
serve/web/app.js(+6 -0)📝
serve/web/index.html(+2 -0)➕
src/core/conversation_cache_disk.cpp(+150 -0)➕
src/core/conversation_cache_disk_test.cpp(+105 -0)📝
src/program/generate.cpp(+27 -1)📄 Description
Why
The parked-conversation cache only had RAM: once
--conversation-cache-mibor the slot count filled,evict_oldest()dropped the oldest conversation, and its next request re-read the entire prompt. On our 4x V100 serving box (long multi-hundred-KB prompts) that re-read is the expensive part, and the eviction happened exactly when memory was under pressure.What
With
--conversation-cache-file-mib > 0(new, plus--conversation-cache-file-dir, default<pack>/conv-cache), eviction now spills: the heavy parts (K/V pages, running state, checkpoint copies) go to<dir>/<serial>.convand a small RAM shell (ids, images, pinned) stays sobest()matching still finds the conversation. A returning conversation is read whole back from disk and the file goes.slots- the slot count bounds RAM and disk entries together; when a slot is needed and the oldest entry is already on disk it leaves for good (its file goes), same when the disk budget is exhausted.borrows()refuses a spilled entry - the restore is all-or-nothing, a half-borrowed K/V never reaches the graph.conversation_snapshot_validategate; a half-written file (crash between write and rename - the write istmp+ rename) is refused, not trusted.0(the default) is upstream behavior, byte-for-byte: eviction drops.server.pycounts the folder named in the engine INFO line;app.jsrenders it; the row hides when the tier is off).Test
conversation_cache_disk_test(registered in theSTRATA_BUILD_TESTSblock): round-trips a 751 MiB synthetic parked image - 100k tokens, 5 K/V pages, 3 checkpoints, 2 stage images, a buffer crossing the 16 MiB segment edge - byte-identical read-back, refuses a truncated file without crashing, and survives an empty image.--servebox for a day: normal serving, monitor row renders, spills restore correctly.Built and tested by the owner's ops agent (hence the
ops@wlwxai.localcommit author). Happy to re-run anything on request.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.