mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1597] [CLOSED] Conversation cache: --conversation-cache-min-tokens parks only conversations of at least N tokens #3553
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#3553
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/1597
Author: @willthehuman
Created: 10/8/2026
Status: ❌ Closed
Base:
main← Head:feat/conversation-cache-min-tokens📝 Commits (1)
433b035Conversation cache: --conversation-cache-min-tokens parks only conversations of at least N tokens📊 Changes
4 files changed (+59 additions, -6 deletions)
View changed files
📝
docs/DETAILS.md(+8 -0)📝
include/strata/core/conversation_cache.hpp(+8 -1)📝
src/core/conversation_cache_test.cpp(+17 -0)📝
src/program/generate.cpp(+26 -5)📄 Description
What this adds
--conversation-cache-min-tokens Nparks only conversations of at least N tokens.0(the default) keeps today's behaviour, so nothing changes unless you set it.Why
Parking happens on a switch, and every parked conversation costs one of
--conversation-cache-slotswhatever its length. A client that interleaves short side requests with one long conversation therefore spends the cache on the side requests, and once it is full,make_room()evicts the long one oldest-first — which is exactly the reuse the cache was turned on for.The case that made me write it: an agent (Hermes) issuing side prompts of a few hundred tokens alongside one long conversation. With
--conversation-cache-slots 2the short requests park themselves, take both slots, and the long conversation is gone by the time its next turn arrives.Measured
RTX 4070 SUPER 12 GB / 32 GB / Linux / Q2_0,
--conversation-cache-mib 2560 --conversation-cache-slots 2. One 19,198-token conversation (L) interleaved with three ~700-token requests, thenLsent again with the same prefix:Lre-sentmin 0Levicted (oldest first)0 reused + 19198 read in 41,059 ms(wall 41.4 s)min 12288skip parking (703 tokens, below the 12288 minimum)×319193 reused + 5 read in 135 ms(wall 0.3 s)304x on the prompt read, 41.4 s → 0.3 s wall. The skip lines are new; the restore line (
restored 19193 tokens (checkpoint) in 68.3 ms) is the existing one.Three side requests are needed to show this: with two, the warm-up conversation is the one evicted and
Lsurvives either way.What does not change
0parks every conversation, whatever its size. Any engine started today behaves identically.make_room(), so a skipped park neither evicts nor stores anything, and it returns the same non-errortruethe byte-budget and RAM-floor paths already take.wants()answers for the length alone; the gate is stillenabled() && wants(), so--conversation-cache-mib 0or--conversation-cache-slots 0still disables parking outright.Plumbed like its neighbours
Option struct, usage text,
from_charsparsing (withINT32_MAXas the range, like--conversation-cache-slots, and negatives rejected), the construction site, the gate, and the startupINFOline — matching what--conversation-cache-mib/-slots/-min-free-mibalready do.Tests
conversation_cache_test.cpp, next to the existingenabled()block:0parks every length, including empty0(the CLI rejects a negative; the predicate should not invert if one arrives another way)Both faults were then reintroduced by hand to confirm the checks catch them —
>=→>failed on "the minimum itself and above are parked", and unconditional-park failed on "below the minimum is not parked".Docs
A paragraph in
docs/DETAILS.mdwith the log line, the default, and why a skipped park is free.Happy to rename the flag or fold it into an existing one if you would rather it live somewhere else — I picked a separate option because it composes with the slot count and the RAM floor rather than replacing either.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.