[GH-ISSUE #2036] Large catalog selectors need cached or paged summary reads #998

Closed
opened 2026-10-21 05:24:58 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Xelvanis on GitHub (Jun 3, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2036

Originally assigned to: @cha1latte on GitHub.

Problem

Large catalog selectors have summary projections, but the measured selector hot paths are still too slow on large profiles and some selector hooks still request full rows.

Current refactor evidence on origin/refactor:

  • Chat summaries use projected fields in src/features/catalog/chats/hooks/use-chat-summaries.ts:46-48 and :63-65.
  • Character panel summaries use projected fields in src/features/catalog/characters/hooks/use-characters.ts:118, :157-160, and :213.
  • The chat surface still fetches full character details by ID via src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.ts:264 -> useCharactersByIds, which calls full storageApi.get("characters") at src/features/catalog/characters/hooks/use-characters.ts:167.
  • Connection selectors list full rows at src/features/catalog/connections/hooks/use-connections.ts:34.
  • Preset selectors have a summary hook, but usePresets, default selection, and default mutation still full-list prompt rows at src/features/catalog/presets/hooks/use-presets.ts:179, :223, and :274.
  • Persona usePersonas still full-lists rows at src/features/catalog/personas/hooks/use-personas.ts:57.
  • Storage projected reads go through src-tauri/crates/storage/src/lib.rs:979 and do not populate an app-level projected summary cache for repeated selector reads.

Scratch large-profile timing on the current Target 2 batch 4 base, using synthetic JSON collections:

  • Character panel-style projected list, 1,200 large cards: 1798.17ms cold / 1681.39ms warm, 5,324,581 payload bytes.
  • Chat summary projected list, 2,500 large chats: 874.68ms cold / 872.68ms warm, 878,891 payload bytes.
  • Full chat list, same 2,500 chats: 135.01ms cold / 17.60ms warm, but 31,748,766 payload bytes.

The projected payloads are much smaller, but repeated summary reads still spend near-cold CPU time because the projected path streams/parses each call instead of serving a cached/indexed summary shape. Full-row selector hooks also keep large payload risk alive.

Expected

Selector/list surfaces should be fast on warm large profiles and avoid loading large detail fields until a detail editor or runtime path actually needs them.

Suggested Fix

  • Add cached or materialized summary/index paths for high-cardinality catalogs, especially character and chat summaries.
  • Use summary-by-id projections in the chat surface when only display/prompt-adjacent fields are needed; reserve full character rows for editors or generation paths.
  • Convert connection, persona, and preset selector hooks to explicit summary projections or paged/search queries where possible.
  • Add cold/warm large-profile proof for character selector, chat sidebar, quick switcher, and preset/connection/persona selectors.
Originally created by @Xelvanis on GitHub (Jun 3, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2036 Originally assigned to: @cha1latte on GitHub. ## Problem Large catalog selectors have summary projections, but the measured selector hot paths are still too slow on large profiles and some selector hooks still request full rows. Current refactor evidence on `origin/refactor`: - Chat summaries use projected fields in `src/features/catalog/chats/hooks/use-chat-summaries.ts:46-48` and `:63-65`. - Character panel summaries use projected fields in `src/features/catalog/characters/hooks/use-characters.ts:118`, `:157-160`, and `:213`. - The chat surface still fetches full character details by ID via `src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.ts:264` -> `useCharactersByIds`, which calls full `storageApi.get("characters")` at `src/features/catalog/characters/hooks/use-characters.ts:167`. - Connection selectors list full rows at `src/features/catalog/connections/hooks/use-connections.ts:34`. - Preset selectors have a summary hook, but `usePresets`, default selection, and default mutation still full-list prompt rows at `src/features/catalog/presets/hooks/use-presets.ts:179`, `:223`, and `:274`. - Persona `usePersonas` still full-lists rows at `src/features/catalog/personas/hooks/use-personas.ts:57`. - Storage projected reads go through `src-tauri/crates/storage/src/lib.rs:979` and do not populate an app-level projected summary cache for repeated selector reads. Scratch large-profile timing on the current Target 2 batch 4 base, using synthetic JSON collections: - Character panel-style projected list, 1,200 large cards: `1798.17ms` cold / `1681.39ms` warm, `5,324,581` payload bytes. - Chat summary projected list, 2,500 large chats: `874.68ms` cold / `872.68ms` warm, `878,891` payload bytes. - Full chat list, same 2,500 chats: `135.01ms` cold / `17.60ms` warm, but `31,748,766` payload bytes. The projected payloads are much smaller, but repeated summary reads still spend near-cold CPU time because the projected path streams/parses each call instead of serving a cached/indexed summary shape. Full-row selector hooks also keep large payload risk alive. ## Expected Selector/list surfaces should be fast on warm large profiles and avoid loading large detail fields until a detail editor or runtime path actually needs them. ## Suggested Fix - Add cached or materialized summary/index paths for high-cardinality catalogs, especially character and chat summaries. - Use summary-by-id projections in the chat surface when only display/prompt-adjacent fields are needed; reserve full character rows for editors or generation paths. - Convert connection, persona, and preset selector hooks to explicit summary projections or paged/search queries where possible. - Add cold/warm large-profile proof for character selector, chat sidebar, quick switcher, and preset/connection/persona selectors.
bsakaguchi 2026-10-21 05:24:58 +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-Engine#998
No description provided.