PERF/MEM: bound the in-memory Log journal and stop retaining one update entry per stream chunk forever #169
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nsaspy/a0-symbolics#169
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?
Finding
helpers/log.py::Logkeeps two unbounded in-memory arrays for the lifetime of a live context:logs: list[LogItem]updates: list[int]Every
_update_item()appendsitem.notoupdates, including repeated streaming updates of the same log item. A long model/tool stream can therefore add thousands of duplicate integers for one logical message. Neither list is compacted untilLog.reset().Persistence already keeps only the last
LOG_SIZE = 1000log items, but the live process retains the complete log and complete update journal. With many eagerly-loaded/long-lived chats this compounds the memory problem tracked in #21.Log.output(start=...)uses the update-list index as its client cursor, so simple list truncation would break current cursor semantics. The journal needs a base/version model or another bounded change-tracking design.Impact
updatesgrows with stream chunks, not just messagesDirection
Use a monotonic log version independent of raw list indexes and keep a bounded update/delta structure.
Possible shape:
versionreset/full snapshot requiredsignal when a client cursor predates retained deltasLogItemsDo not silently drop information the active UI is expected to show. If full durable history is desired, store it durably instead of pinning it forever in every live Python context.
Acceptance
Mirrored from
lost-rob0t/a0-symbolics#31via tracker sync.