Skip to content

Client: limit warm session residency by estimated size - #139

Open
katulevskiy wants to merge 3 commits into
mirror/upstream-mainfrom
mirror/upstream-pr/626
Open

katulevskiy wants to merge 3 commits into
mirror/upstream-mainfrom
mirror/upstream-pr/626

Conversation

@katulevskiy

Copy link
Copy Markdown
Owner

Upstream mirror

Source: zeronsh#626
Original author: @katulevskiy
Original revision: 86952e4da77d8eb2f4ff70f5dd4c09ab2b9a3a86

This PR is an isolated Contribution Manager pilot mirror. Its reviews, checks and merge state are separate from upstream. An empty [skip ci] commit suppresses automatic bulk CI; the code tree matches the imported upstream revision.


Summary

  • The warm-session cap counted sessions, so six large chats stayed resident on a phone as readily as six small ones. Byte-based residency lived in the old Swift store, which is gone, and the Rust core only had the count cap.
  • evict_sessions still applies the cap of 6 and now also evicts least-recently-used detached, quiet sessions until the estimated resident total fits a 32 MB budget. Pinned sessions (on screen, streaming, pending sends) count toward the total but are never evicted, and neither is the most recently used session.
  • The estimate is the one the desktop doc LRU already uses (snapshot bytes x 6, 512 KB floor). It moves into zeron-doc so both share it, and the engine now calls it. The client sizes a doc by exporting a snapshot, cached per session until its op count changes.
  • Evicted sessions are now flushed explicitly before they are dropped, outside the session-map lock, so a handle held elsewhere can't leave the debounced save pending.
  • 32 MB is 40% of the desktop's 80 MB budget. docs/memory-plan.md targets 150-250 MB for the whole app, 48 MB of which is already the attachment cache, so I'm happy to adjust the number.
  • A session with unacknowledged local writes is pinned, so it can stay over budget.
  • Opened as a draft because it touches zeron-doc and zeron-engine as well as the client. No UniFFI changes.

katulevskiy and others added 2 commits September 28, 2026 21:07
The warm-session cap counted sessions, so six 5MB chats stayed resident
on a phone as readily as six tiny ones. Byte-based residency lived in the
old Swift store, which is gone; the Rust core only had the count cap.

evict_sessions now also evicts least-recently-used detached, quiet
sessions until the estimated resident total (all open sessions, including
pinned ones) fits a 32MB budget. The count cap stays as an upper bound.
The most recently used session is never picked, so a session that was
just opened (not yet attached) survives even if it alone is over budget.

The estimate is the desktop doc LRU's (snapshot bytes x 6, 512KB floor),
hoisted into zeron-doc so both share it. The client sizes a doc by
exporting a snapshot, cached per session until its op count changes.

Evicted sessions are now flushed explicitly before being dropped, and
outside the session-map lock, so a handle held elsewhere can't leave the
debounced save pending.
@contribution-manager-katulevskiy contribution-manager-katulevskiy Bot added the review:needs-triage Managed by Contribution Manager label Oct 6, 2026
@contribution-manager-katulevskiy

contribution-manager-katulevskiy Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Contribution Manager

needs triage · medium risk · untriaged

Open review workspace · Revision f02f873b

Next actions:

  • Direction decision needed
  • Scope, risk, and platform triage needed
  • Independent code review needed
  • Required check: core-tests (missing)

This summary is maintained by the review app. Decisions and test evidence are recorded in the workspace; the app does not merge PRs.

@contribution-manager-katulevskiy contribution-manager-katulevskiy Bot added cm:inbox Contribution Manager: waiting for triage and removed review:needs-triage Managed by Contribution Manager labels Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cm:inbox Contribution Manager: waiting for triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant