mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4224] [Engine] Add opt-in parked cache deduplication #4958
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#4958
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/4224
Author: @4f1sh3r
Created: 10/26/2026
Status: 🔄 Open
Base:
main← Head:parked-cache-dedup📝 Commits (1)
57d6238[Engine] Add opt-in parked cache deduplication📊 Changes
16 files changed (+852 additions, -45 deletions)
View changed files
📝
CMakeLists.txt(+5 -0)➕
docs/PARKED_CACHE_DEDUP.md(+114 -0)📝
include/strata/core/conversation_buffer.hpp(+33 -5)📝
include/strata/core/conversation_cache.hpp(+160 -18)📝
include/strata/core/conversation_snapshot.hpp(+6 -2)➕
include/strata/core/conversation_storage.hpp(+247 -0)📝
include/strata/core/session_save_reclaim.hpp(+2 -0)📝
serve/server.py(+4 -0)📝
src/core/conversation_copy.hpp(+12 -0)📝
src/core/conversation_file.cpp(+3 -2)📝
src/core/conversation_snapshot.cpp(+16 -7)📝
src/core/conversation_snapshot_test.cpp(+17 -6)📝
src/core/conversation_state.cpp(+8 -2)📝
src/core/conversation_validation_test.cpp(+4 -1)📝
src/program/generate.cpp(+37 -2)➕
tests/core/conversation_storage_test.cpp(+184 -0)📄 Description
Problem and result
With the conversation cache enabled, every parked conversation keeps its own full copy of the conversation bytes, so shared prefixes and repeated turns are charged against the cache budget several times.
On a RAM-constrained host the cache then evicts or refuses parked histories while identical bytes already sit in RAM. Measured on a 192 GiB host with a 40 GiB cache budget, the unpatched engine retained 41 conversations at 92.7 GiB RSS where dedup keeps 64 at 73.2 GiB.
With
STRATA_PARKED_DEDUP=1, identical parked payloads are stored once and shared. In three days of production (single RTX 3090, 64 slots, 40 GiB budget) the engine reports 33.7 GB logical against 25.3 GB physical parked bytes (~8.5 GB saved, ~25%), 7000+ dedup hits and zero budget evictions. Unset, behaviour is unchanged.Related discussion
none
Approach
A content-addressed immutable parked storage layer (
include/strata/core/conversation_storage.hpp): snapshots reference shared payloads, copy-on-write on divergence, and budget/RAM admission plus eviction planning now account physical (shared) bytes plus a metadata bound instead of logical bytes.Opt-in via one environment variable; mode 0 keeps the pre-patch code paths, fingerprint-compared against the unpatched engine. A refused
put()keeps superseded copies until the image fits, and the RAM gate trims the heap before evicting, because freed 1 MiB blocks can otherwise stay in the heap and not show up inMemAvailable. Diagnostics: aconversation_cache.dedupblock in/metricsand one stats line per park. Design notes indocs PARKED_CACHE_DEDUP.md. No defaults changed, no unrelated cleanup.Validation
Passed:
New
tests/core/conversation_storage_test.cpp, wired into CMake and run with:at
7ddc17a3(v0.2.3.1) and at this revision on4b9e05a2(v0.2.6): 519checks with dedup disabled, 608 enabled, 608 with forced hash collisions.
Existing engine unit suites on the CUDA build host, in both dedup modes:
snapshot 4041, validation 972, transfer and failure injection 1548,
serialization 201, memory 31, split allocation failures 8/12/16, cache policy
4772 (disabled), memory guard 156. Storage fixture also green under
ASan+UBSan.
Controlled full-model probes (31 requests each, one output token,
STRATA_PREFILL_CPU_SHARE=0): unpatched, patched-off and patched-on producedidentical outputs and identical GDN/PLE/tail/index/KV state fingerprints.
Budget-bound synthetic A/B (89 requests, 10240 MiB budget, 64 slots, 64
conversations sharing a 24576-token prefix): no regression in retained
histories, evictions or decode speed against the off arm.
Applied unchanged and re-validated on
4b9e05a2(engine 0.1.51): unit suitesgreen, running in production since 2026-10-25, including a service restart on
2026-10-26.
Environment: Linux x86-64 (Threadripper 5965WX, 192 GiB RAM), single RTX 3090,
CUDA 13.2, Release build.
Failed:
none observed
Not run:
3090 host.
only the refusal itself was exercised.
is covered by review and allocator reasoning, not by a live OOM test.
Limits
message when combined with stages or batch.
upstream behaviour, unchanged here.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.