[PR #1394] [CLOSED] serve: evict parked conversations to pass the physical-RAM gate instead of dropping the snapshot #3426

Closed
opened 2026-11-07 14:41:25 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1394
Author: @Arthur031221
Created: 10/7/2026
Status: ❌ Closed

Base: main ← Head: conversation-cache-evict-for-ram-gate


📝 Commits (1)

  • e6dd58f serve: a full conversation cache evicts to pass the physical-RAM gate instead of dropping the snapshot

📊 Changes

6 files changed (+229 additions, -9 deletions)

View changed files

📝 include/strata/core/conversation_cache.hpp (+51 -7)
📝 include/strata/core/conversation_memory.hpp (+4 -0)
📝 src/core/conversation_cache_test.cpp (+124 -0)
📝 src/core/conversation_memory.cpp (+10 -0)
📝 src/core/conversation_memory_test.cpp (+29 -0)
📝 src/program/generate.cpp (+11 -2)

📄 Description

Title

Issue: Resolves #1347

Summary

With a full conversation cache and little free host RAM, a long conversation wasn't parked even when the parked ones held more RAM than the snapshot needed. The next request had to read its whole prompt again (270k tokens, 96 s, 32 times in the reporter's log).

What changed

When the plain RAM check refuses, it now calls malloc_trim(0) to give freed heap back (glibc keeps freed segments in its heap) and reads free RAM again. If that's still not enough, it evicts the oldest parked conversations one at a time, reading again after each, until the snapshot fits. Pinned prefixes stay, as in make_room(). Nothing is evicted if the host reports no figure or the parked ones can't cover it.

Extra Notes

Builds on the code @alanthinker posted in #1347 (github.com/alanthinker/Strata@c62b540). Tested with new cases in conversation_cache_test and conversation_memory_test (-DSTRATA_BUILD_CONVERSATION_TESTS=ON).

I used Claude/Codex to assist with preparing, checking and double-checking this change.

Co-authored-by: Alanthinker Xiang 11045022+alanthinker@users.noreply.github.com


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/1394 **Author:** [@Arthur031221](https://github.com/Arthur031221) **Created:** 10/7/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `conversation-cache-evict-for-ram-gate` --- ### 📝 Commits (1) - [`e6dd58f`](https://github.com/Niko1221/Strata/commit/e6dd58f93eb6f15f9caaa5252afce7ca0161352e) serve: a full conversation cache evicts to pass the physical-RAM gate instead of dropping the snapshot ### 📊 Changes **6 files changed** (+229 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/core/conversation_cache.hpp` (+51 -7) 📝 `include/strata/core/conversation_memory.hpp` (+4 -0) 📝 `src/core/conversation_cache_test.cpp` (+124 -0) 📝 `src/core/conversation_memory.cpp` (+10 -0) 📝 `src/core/conversation_memory_test.cpp` (+29 -0) 📝 `src/program/generate.cpp` (+11 -2) </details> ### 📄 Description ## Title Issue: Resolves #1347 ## Summary With a full conversation cache and little free host RAM, a long conversation wasn't parked even when the parked ones held more RAM than the snapshot needed. The next request had to read its whole prompt again (270k tokens, 96 s, 32 times in the reporter's log). ## What changed When the plain RAM check refuses, it now calls `malloc_trim(0)` to give freed heap back (glibc keeps freed segments in its heap) and reads free RAM again. If that's still not enough, it evicts the oldest parked conversations one at a time, reading again after each, until the snapshot fits. Pinned prefixes stay, as in `make_room()`. Nothing is evicted if the host reports no figure or the parked ones can't cover it. ## Extra Notes Builds on the code @alanthinker posted in #1347 (https://github.com/alanthinker/Strata/commit/c62b540). Tested with new cases in `conversation_cache_test` and `conversation_memory_test` (`-DSTRATA_BUILD_CONVERSATION_TESTS=ON`). I used Claude/Codex to assist with preparing, checking and double-checking this change. Co-authored-by: Alanthinker Xiang <11045022+alanthinker@users.noreply.github.com> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 14:41:25 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#3426
No description provided.