Repository navigation
The window's memory: UI trees kept only for a reader, once per run; the page's code handed over once - #185
Merged
Conversation
shinyobjectz
force-pushed
the
window-trees
branch
from
November 18, 2026 21:01
72b73e4 to
71ccb37
Compare
…he page's code handed over once raea's page host kept the last 240 frames' UI trees (tree.rs TREES) for the MCP ui tool. It did that in the person's app too, where the MCP server is off and nothing reads them: 315 MB of serde_json trees with a feed of 120 cards open, found by MallocStackLogging in raea-feed's e2e/memory.spec.ts (MEM_STACKS). - The trees are kept only once the MCP server serves (tree::KEEP, set by mcp::serve). LATEST, which BRP's ui method reads, is kept as before. - The frames the MCP reader was handed already (tree::SEEN) are let go: its next ask is always for a later frame. - Frames in a row whose trees are the same are kept once, with their first frame, and handed out as each frame. A page at rest is one tree however long it rests, and every reader gets what it got before. The page host's main also hands the page's code to the mount once instead of keeping it for the app's whole life: the feed's bundle is 21 to 26 MB. raea-feed's memory spec, 60 stills of 2560x1440, with raea #184 and raea-feed #97: | Stage | 0.1.8-rc3 | Now | |---|---|---| | Feed open | 1131 MB | 757 MB | | End of feed | 2032 MB | 904 MB | | After opening items | 2526 MB | 1317 MB | Unit tests (tree::tests) cover: - a run handed out frame by frame; - what was handed out let go; - a run part-way through kept; - the 240 cap.
shinyobjectz
force-pushed
the
window-trees
branch
from
November 18, 2026 21:15
71ccb37 to
cba2c33
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why. raea's window ran at about 3 GB. This is the last of three pieces; the others are #184 (pictures decoded at the size their URL asks) and shinyobjectz/raea-feed#97 (the feed asks for that size and lets far cards go).
The finding. A malloc stack log of the window at the end of a 120-card feed (raea-feed's
e2e/memory.spec.ts,MEM_STACKS) put 315 MB of the live heap intree::answer. Every frame, the page host built the UI tree and kept the last 240 copies (TREES) for the MCPuitool. That happened in the person's app too, where the MCP server is off (RAEA_PAGE_MCP_PORT=0) and nothing reads them. A tree grows with the page, so in a long feed this looked like each card costing 2.9 MB.Changes
tree.rs. Trees are kept only once the MCP server serves (KEEP, set inmcp::serve).LATEST, which BRP'suimethod reads, is unchanged.SEEN, moved here from mcp.rs) are let go, since its next ask is always for a later frame.Kept).tree_afterhands out what frame N showed, with frame N, so readers get exactly what they got before.main.rs. The page's code goes to the mount once instead of being cloned and kept for the process's life. The feed's bundle is 21 to 26 MB.Size. The crate stays under
tools/size.sh's 2000-line limit (1992).Measured. raea-feed's memory spec, 60 stills of 2560×1440, with all three PRs:
At 120 stills the end of the feed is 1019 MB. Before this PR it was 1294 MB with the other two fixes in.
Tests.
cargo test --release -p raea-page-host --features window --lib tree::: two tests coveringThe memory spec drives the page host through MCP throughout, so it also exercised the
uitool's frame-in-turn reads on this build.🤖 Generated with Claude Code