[GH-ISSUE #1514] [Issue]: Long-Term Memory: the Memory Vault slows down with many memories because it draws every row #1500

Closed
opened 2026-10-22 04:02:44 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (Oct 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1514

Originally assigned to: @Promansis on GitHub.

Summary

The Memory Vault slows down as a place gets more memories, because it draws a row for every memory, even inside closed groups, and every search letter redraws all of them. At 8,000 memories a single letter can take 3–4 s on a fast desktop and 13 s on a phone-speed CPU, and opening the Vault stalls the page for 1.7 s (6 s on the phone proxy). Even the real 197-memory vault crosses 100 ms on the first letter.

Affected package

long-term-memory 1.4.55 (upstream/staging 8b72729f1). Measured on 1.4.54 (UI-1) and re-timed on 1.4.55; the Vault client is unchanged since 1.4.53.

C = packages/long-term-memory/src/engine/packages/client/src/features/long-term-memory

Expected behavior

  • Each letter typed into the Vault search appears at once, and the list catches up within a fraction of a second, whatever the size of the vault.
  • Opening the Vault doesn't stall the page while thousands of rows are built.
  • Search, the filters, the group counts and Select visible still cover every memory in the place, not only the rows on screen.

Actual behavior

Measured with the UI-1 harness (headless Chromium, Ryzen 5 3600X; the phone proxy is 4× CPU throttling on the Pixel 7 viewport). Each letter waits for the whole list, so "input" and "results" are the same time:

Memories Open, desktop / phone ×4 Worst letter, desktop Worst letter, phone ×4 Heap DOM nodes
197 0.17–0.21 s / 0.67 s 110–140 ms 704 ms 7 MB 5.9k
2,000 0.53–0.62 s / 2.0 s 830–860 ms 3.0 s 30 MB 58k
8,000 1.7–1.9 s / 6.1 s 3.2–3.9 s 13.4 s 107–111 MB 229k
20,000 3.7–4.3 s / 15.3 s 8.2–9.5 s 29.1 s 260 MB 573k

When typing at a normal pace, keys queue behind the renders: at 8,000 memories on desktop the worst letter appears after 4.7 s, and on the phone proxy 28 letters take 80 s to work through.

Cause (CPU profile at 8,000 memories):

  • Every memory in the place renders a row of about 29 DOM nodes, even when its group is closed, and a non-empty search opens every group (C/vault/MemoryVault.tsx:2504-2527 in the base).
  • The work is laying out, rendering and committing those rows: layout 9.1 s, rendering 4.5 s and DOM commit about 1.5 s of the profile. MemoryVault's own render code is about 1.2 s, roughly 8%.
  • The filtered list (:700) and the row previews are rebuilt on every render with the current text, so the letter can't paint before the list is rebuilt.

Steps to reproduce

  1. Use a place with a few thousand memories.
  2. Open Long-Term Memory, then Vault.
  3. Type a letter that matches most memories into Search memories. The letter appears only after the whole list has been rebuilt.
  4. Clear the search: the closed groups still take about 0.5 s at 8,000, because every row exists inside them.

Minimal fix

One PR, patch bump. Client only: the small fix plus a 100-row cap per group with Show more, and no screen split.

  1. Deferred search in C/vault/MemoryVault.tsx: useDeferredValue(search) drives the filter, the previews and the open groups. The filtered, sorted list is a useMemo, so the letter paints first and the list follows.
  2. Memoized rows: the row moves to a new C/vault/VaultRow.tsx, a React.memo component with primitive props. Its handlers go through a ref that MemoryVault updates on every render, so a row only re-renders when its own data changes. The row markup is unchanged apart from a data-ltm-note-id attribute.
  3. 100 rows per group: each type group renders its first 100 rows, then a full-width "Show N more" button (ui.longTermMemory.memoryvault.showMoreMemories, "Show {{value1}} more", N at most 100). The button names its group through aria-describedby, adds the next 100 rows and moves focus to the first row it added. A new search, filter, sort or place starts again at 100.
  4. Unchanged: the group count and the "N shown" total count every memory, search and the filters run over every memory, and Select visible ticks every filtered memory, as before.
  5. packages/long-term-memory/docs/UI.md: the Memory Vault contract gains the cap and what it does not change.
  • CHANGELOG under ## Unreleased: one bullet, for example: "The Vault stays responsive in places with many memories. Letters typed into the search appear at once and the list follows, and each type shows its first 100 memories with a Show more button. Search, the filters, the counts and Select visible still include every memory."

Not included

  • The screen split (A-003, A-005), which this item originally proposed, together with adopting useMutation. The profile shows the screen's own code is about 8% of the work, so the split would not make the Vault faster. It stays an optional architecture tidy-up.
  • Server-side search and paging (UI-8, dropped). The Vault still downloads every memory in the place on open: 20.9 MB at 8,000.
  • A virtualized list, or a cached lowercase search string per memory. These might get the list update under 100 ms but were not measured.
  • Revealing a memory beyond the first 100 when it is opened from a link. The detail opens as before, but its row stays hidden until Show more. The base doesn't scroll the navigator to the selected row either.

Regression proof

In tests/long-term-memory-browser.regression.ts, a new block after the desktop debug rows. A place with 250 world memories, one of them (number 230) mentioning a lighthouse:

  1. The world group shows "250 shown" and a count of 250, but renders 100 rows. Today it renders all 250 (250 !== 100).
  2. Show 100 more, pressed with Enter, renders 200 rows and moves focus to "Capped memory 100". A "Show 50 more" button follows.
  3. Searching "lighthouse" shows memory 230, which is beyond the first 100.
  4. Clearing the search shows "250 shown" and 100 rows again.

tests/long-term-memory-feedback-clarity-ui.regression.mjs reads the row's classes from VaultRow.tsx (new entry in tests/long-term-memory-source-paths.mjs).

Environment

  • Marinara Engine version: 2.5.0 line (local staging checkout, unchanged; Playwright Chromium 153 from its node_modules)
  • Package version: long-term-memory 1.4.55 (upstream/staging 8b72729f1)
  • Install type: source (browser regression harness and timing harness, throwaway copy)
  • OS + version: Linux 6.8, Node 24.15.0
  • Browser or app shell: Chromium (Playwright, headless)

Logs, screenshots, or video

UI-1's full write-up and its data are kept privately. The fixture clones the 197 real notes, so sizes and search match rates follow real data, and the mock answers every place with the whole fixture.

Re-timed with the fix on 1.4.55 (2026-10-20), 8,000 memories, base and patched interleaved in one run. The raw data and the full table are kept privately; the summary:

8,000 memories Open Worst letter (over 100 ms of 28) List shows the letter, worst Heap
Today, desktop 1.6–1.8 s 3.0–3.2 s (24) same as the letter 110 MB
With the fix, desktop 0.65 s 50 ms (0) 0.33 s 42 MB
Today, phone ×4 5.9 s 11.4 s (28) same as the letter 108 MB
With the fix, phone ×4 2.1 s 138 ms (5) 1.2 s 43 MB

Typing a key every 150 ms on desktop, 28 keys now take 4.2 s instead of 16.4 s, and the worst letter is 295 ms instead of 3.6 s. The results match UI-1's measurement of the same approach (variant C) within run-to-run noise.

Additional context

Tracker items UI-2 (this change) and UI-1 (the timing checkpoint that measured it). UI-2 first read "split state ownership in the screens (A-003, A-005), starting with the Vault". UI-1 showed that drawing fewer rows is what helps, so this fix replaces the split.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Oct 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1514 Originally assigned to: @Promansis on GitHub. ## Summary The Memory Vault slows down as a place gets more memories, because it draws a row for every memory, even inside closed groups, and every search letter redraws all of them. At 8,000 memories a single letter can take 3–4 s on a fast desktop and 13 s on a phone-speed CPU, and opening the Vault stalls the page for 1.7 s (6 s on the phone proxy). Even the real 197-memory vault crosses 100 ms on the first letter. ## Affected package `long-term-memory` 1.4.55 (`upstream/staging` 8b72729f1). Measured on 1.4.54 (UI-1) and re-timed on 1.4.55; the Vault client is unchanged since 1.4.53. `C` = `packages/long-term-memory/src/engine/packages/client/src/features/long-term-memory` ## Expected behavior - Each letter typed into the Vault search appears at once, and the list catches up within a fraction of a second, whatever the size of the vault. - Opening the Vault doesn't stall the page while thousands of rows are built. - Search, the filters, the group counts and Select visible still cover every memory in the place, not only the rows on screen. ## Actual behavior Measured with the UI-1 harness (headless Chromium, Ryzen 5 3600X; the phone proxy is 4× CPU throttling on the Pixel 7 viewport). Each letter waits for the whole list, so "input" and "results" are the same time: | Memories | Open, desktop / phone ×4 | Worst letter, desktop | Worst letter, phone ×4 | Heap | DOM nodes | |---:|---:|---:|---:|---:|---:| | 197 | 0.17–0.21 s / 0.67 s | 110–140 ms | 704 ms | 7 MB | 5.9k | | 2,000 | 0.53–0.62 s / 2.0 s | 830–860 ms | 3.0 s | 30 MB | 58k | | 8,000 | 1.7–1.9 s / 6.1 s | 3.2–3.9 s | 13.4 s | 107–111 MB | 229k | | 20,000 | 3.7–4.3 s / 15.3 s | 8.2–9.5 s | 29.1 s | 260 MB | 573k | When typing at a normal pace, keys queue behind the renders: at 8,000 memories on desktop the worst letter appears after 4.7 s, and on the phone proxy 28 letters take 80 s to work through. Cause (CPU profile at 8,000 memories): - Every memory in the place renders a row of about 29 DOM nodes, even when its group is closed, and a non-empty search opens every group (`C/vault/MemoryVault.tsx:2504-2527` in the base). - The work is laying out, rendering and committing those rows: layout 9.1 s, rendering 4.5 s and DOM commit about 1.5 s of the profile. `MemoryVault`'s own render code is about 1.2 s, roughly 8%. - The filtered list (`:700`) and the row previews are rebuilt on every render with the current text, so the letter can't paint before the list is rebuilt. ## Steps to reproduce 1. Use a place with a few thousand memories. 2. Open Long-Term Memory, then Vault. 3. Type a letter that matches most memories into Search memories. The letter appears only after the whole list has been rebuilt. 4. Clear the search: the closed groups still take about 0.5 s at 8,000, because every row exists inside them. ## Minimal fix One PR, patch bump. Client only: the small fix plus a 100-row cap per group with Show more, and no screen split. 1. **Deferred search** in `C/vault/MemoryVault.tsx`: `useDeferredValue(search)` drives the filter, the previews and the open groups. The filtered, sorted list is a `useMemo`, so the letter paints first and the list follows. 2. **Memoized rows**: the row moves to a new `C/vault/VaultRow.tsx`, a `React.memo` component with primitive props. Its handlers go through a ref that `MemoryVault` updates on every render, so a row only re-renders when its own data changes. The row markup is unchanged apart from a `data-ltm-note-id` attribute. 3. **100 rows per group**: each type group renders its first 100 rows, then a full-width "Show N more" button (`ui.longTermMemory.memoryvault.showMoreMemories`, "Show {{value1}} more", N at most 100). The button names its group through `aria-describedby`, adds the next 100 rows and moves focus to the first row it added. A new search, filter, sort or place starts again at 100. 4. Unchanged: the group count and the "N shown" total count every memory, search and the filters run over every memory, and Select visible ticks every filtered memory, as before. 5. `packages/long-term-memory/docs/UI.md`: the Memory Vault contract gains the cap and what it does not change. - **CHANGELOG under `## Unreleased`:** one bullet, for example: "The Vault stays responsive in places with many memories. Letters typed into the search appear at once and the list follows, and each type shows its first 100 memories with a Show more button. Search, the filters, the counts and Select visible still include every memory." **Not included** - **The screen split** (A-003, A-005), which this item originally proposed, together with adopting `useMutation`. The profile shows the screen's own code is about 8% of the work, so the split would not make the Vault faster. It stays an optional architecture tidy-up. - **Server-side search and paging** (UI-8, dropped). The Vault still downloads every memory in the place on open: 20.9 MB at 8,000. - A virtualized list, or a cached lowercase search string per memory. These might get the list update under 100 ms but were not measured. - Revealing a memory beyond the first 100 when it is opened from a link. The detail opens as before, but its row stays hidden until Show more. The base doesn't scroll the navigator to the selected row either. ## Regression proof In `tests/long-term-memory-browser.regression.ts`, a new block after the desktop debug rows. A place with 250 world memories, one of them (number 230) mentioning a lighthouse: 1. The world group shows "250 shown" and a count of 250, but renders 100 rows. Today it renders all 250 (`250 !== 100`). 2. Show 100 more, pressed with Enter, renders 200 rows and moves focus to "Capped memory 100". A "Show 50 more" button follows. 3. Searching "lighthouse" shows memory 230, which is beyond the first 100. 4. Clearing the search shows "250 shown" and 100 rows again. `tests/long-term-memory-feedback-clarity-ui.regression.mjs` reads the row's classes from `VaultRow.tsx` (new entry in `tests/long-term-memory-source-paths.mjs`). ## Environment - Marinara Engine version: 2.5.0 line (local `staging` checkout, unchanged; Playwright Chromium 153 from its `node_modules`) - Package version: long-term-memory 1.4.55 (`upstream/staging` 8b72729f1) - Install type: source (browser regression harness and timing harness, throwaway copy) - OS + version: Linux 6.8, Node 24.15.0 - Browser or app shell: Chromium (Playwright, headless) ## Logs, screenshots, or video UI-1's full write-up and its data are kept privately. The fixture clones the 197 real notes, so sizes and search match rates follow real data, and the mock answers every place with the whole fixture. Re-timed with the fix on 1.4.55 (2026-10-20), 8,000 memories, base and patched interleaved in one run. The raw data and the full table are kept privately; the summary: | 8,000 memories | Open | Worst letter (over 100 ms of 28) | List shows the letter, worst | Heap | |---|---:|---:|---:|---:| | Today, desktop | 1.6–1.8 s | 3.0–3.2 s (24) | same as the letter | 110 MB | | With the fix, desktop | 0.65 s | 50 ms (0) | 0.33 s | 42 MB | | Today, phone ×4 | 5.9 s | 11.4 s (28) | same as the letter | 108 MB | | With the fix, phone ×4 | 2.1 s | 138 ms (5) | 1.2 s | 43 MB | Typing a key every 150 ms on desktop, 28 keys now take 4.2 s instead of 16.4 s, and the worst letter is 295 ms instead of 3.6 s. The results match UI-1's measurement of the same approach (variant C) within run-to-run noise. ## Additional context Tracker items UI-2 (this change) and UI-1 (the timing checkpoint that measured it). UI-2 first read "split state ownership in the screens (A-003, A-005), starting with the Vault". UI-1 showed that drawing fewer rows is what helps, so this fix replaces the split. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-22 04:02:44 +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
Pasta-Devs/Marinara-Agents#1500
No description provided.