mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #5253] [Engine] conversation cache: an opt-in store seam that hands out file descriptors #3125
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#3125
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?
Originally created by @G0-0000 on GitHub (Nov 4, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5253
What
I would like to agree the scope of a narrow seam in the conversation cache before writing any code.
Today
ConversationStore(the artifact-level layer under the disk cache) maps a cache name to a local path. A store that cannot hand out its own file has to materialise a temporary copy, which costs one full write and one full read of the snapshot. That is fine for a test backend and expensive for anything else.Proposal: add three opt-in methods to the store.
lease_read(name)returns an open descriptor (passed with SCM_RIGHTS) and a lease that covers the whole read: both passes of the session file and the delta chain.stage_write(name)andstage_append(name, committed)return a descriptor that the existing writer fills.commit_write(name, bytes)performs the rename and the directory flush.The local store implements them with the calls it already makes. A store that does not implement them falls back to today's path and
materialize. Defaults do not change and the default path stays byte-identical.Why
#4226 and #1937 are two disk-cache designs, and #3485 measures another layout. A user who wants a different medium or a different eviction policy currently has to patch the engine and rebuild it.
A descriptor-based seam lets one external process own placement, eviction and accounting while the engine keeps the byte path: the same O_DIRECT reads and writes, with no copy through another process.
It also gives deletion the lifetime it needs. The reader opens the file twice (a validate pass and an apply pass) and reopens it for every delta record, so
unlinkis only safe when a lease covers the whole operation, not a single descriptor.Non-goals
SCM_RIGHTSis POSIX-only, so an external store is a POSIX capability from day one. Windows keeps the local store and today's path;DuplicateHandleover a named pipe is a different mechanism and stays out of scope.Question
Is a three-commit, opt-in PR in scope?
RawFileadopting an external descriptor, plus the fd read entry points.Publishersplit into stage and commit.If yes, should the protocol details live here or in a separate issue?
Environment
Tesla V100-SXM2 32 GB · 128 GB RAM · Ubuntu Linux · engine 0.1.56.30 (app 0.2.10). This is the machine the disk cache in #4226 was measured on.
@github-actions[bot] commented on GitHub (Nov 4, 2026):
Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:
Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment
/reopen.Details: CONTRIBUTING.md
@udqe commented on GitHub (Nov 5, 2026):
A user-side yes to the scope question, with two of your claims confirmed from the running engine's side and one cross-OS wrinkle worth a line in the scope doc before anyone codes.
The numbers your seam would move are real on a production box. Windows 11, 2x RTX 4090, 128 GB RAM, engine 0.1.56, conversation cache 12 GiB in 4 slots. Today's boot logged, verbatim:
conversation cache: parked 176099 tokens in 2022.1 ms; parked=1 bytes=3524505280 evictions=0- a single conversation park is 3.3 GiB of snapshot and two seconds of write; the second park added another 3.6 GiB (cumulative 7,364,180,760 bytes) - and then the eviction path fired for real:conversation cache: evicted 1 parked conversation to admit this snapshot (3301 MiB plus 2560 MiB floor). So the two things your issue makes extensible - the materialize double-copy and the eviction policy - are exactly the two that cost us real bytes and real seconds at ordinary chat sizes. A seam where an external process owns placement and eviction without a copy through it is a feature this user would switch on.Your lifetime argument matches the code as shipped. The
RawFile/Publisherpair insrc/core/conversation_file.cppexists in exactly the two platform shapes your design implies (the WindowsPublisherat :277 with itsDeleteFileWtemp cleanup, the POSIX one at :465), and the O_DIRECT your byte path relies on is not even a fixed open flag - it is switched onto the open descriptor viafcntlwith a fall back to buffered I/O when the filesystem refuses (:443-452). Which is to say: an external store handing you an already-open descriptor is compatible with how the reader actually behaves (it wants an fd, a path is just how it currently gets one), and your lease-over-the-whole-operation requirement is the right shape - the reopen-per-delta pattern means a per-descriptor lease is not a lease.The wrinkle: SCM_RIGHTS is POSIX-only, and one meaningful slice of conversation-cache production is Windows (this box among them, judging by the tracker's reports). Your opt-in framing makes Windows SAFE - the local store keeps its current path and the default is byte-identical - but the external-store capability would be POSIX from day one, since Windows fd passing is
DuplicateHandleover a named pipe, a genuinely different mechanism. That is not an argument against the seam; it is an argument for one sentence in the Non-goals saying the protocol is POSIX-first, so a reviewer is not left wondering whether the WindowsPublisherwas forgotten when it was deliberately left alone.On your three questions: yes, the commit split reads in the right order (fallback-first, then the fd read entry points, then the write path - each commit reviewable with the default path untouched), and keep the protocol in this issue until commit 3, then summarize the final wire format in that PR's body so the review trail stays in one place.
Housekeeping from someone who has lived with that bot: your issue is missing the machine-spec field and the auto-note says it closes in five days - edit the description and it goes away on its own; this is exactly the kind of thread the tracker cannot afford to lose to a template.
Scope note: I am a user, not a reviewer - my checks here are code-reading of the shipped tree (main at 2026-11-03) and my own engine's log; I have not built or run your seam because it does not exist yet, which is rather the point of the issue.
(ai-assisted; our quoted lines from production boot 2026-11-04 14:36, protocol disclosed in the #3976/#5031 footers)
@github-actions[bot] commented on GitHub (Nov 5, 2026):
Thanks, this follows the format now.
@G0-0000 commented on GitHub (Nov 5, 2026):
Thanks, both points taken.
On the numbers: your park and eviction figures are exactly the cost this seam exists to remove. Our own measurements are on a single V100-32G Linux box (#4226), so I make no claim about the Windows slice either way; your log is the only Windows figure in this thread and I quote it as yours.
The Windows Publisher is deliberately left alone, not forgotten: the default path stays byte-identical.
Still waiting on a maintainer for the scope question itself.