[GH-ISSUE #8606] [Issue]: Avoid reparsing unchanged message extras in Advanced Memory #8423

Closed
opened 2026-11-07 16:42:52 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @gcyrus on GitHub (Oct 31, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/8606

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Advanced Memory reparses every stored message's unchanged extra metadata each time it builds a context. On large chats this creates excessive allocation and garbage collection, which can stall the Node event loop during generation.

Expected behavior

Each unchanged message extra should be parsed once per Advanced Memory service lifetime and reused. Edited or deleted messages must invalidate or remove only their own cached entry.

Actual behavior

Every Advanced Memory context rebuild calls object(message.extra) for every stored message, even when the message metadata has not changed. A CPU profile of a large chat attributed roughly 209 seconds to this work and roughly 107 seconds to garbage collection during the captured interval.

Steps to reproduce

  1. Create or import a Roleplay or Game chat with a large stored-message history and Advanced Memory enabled.
  2. Run repeated Advanced Memory operations or large generations without editing the historical messages.
  3. Profile the server during context construction.
  4. Observe repeated parsing of every message extra and associated allocation/GC work.

Environment

  • Marinara Engine version: source checkout at the current staging baseline
  • Install type: Docker
  • OS + version: Linux 6.8.0-147-generic
  • Browser or app shell: not collected

Logs, screenshots, or video

The local CPU profile showed repeated object(message.extra) parsing as the primary Advanced Memory context-construction cost. No user-authored prompt content is included.

Additional context

The proposed narrow fix is a chat/message cache keyed by the raw stored extra value, with pruning for deleted messages and a regression covering reuse and targeted invalidation.

I could not assign this issue to the authenticated GitHub account. @SpicyMarinara, please assign an owner if needed.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @gcyrus on GitHub (Oct 31, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/8606 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Advanced Memory reparses every stored message's unchanged `extra` metadata each time it builds a context. On large chats this creates excessive allocation and garbage collection, which can stall the Node event loop during generation. ## Expected behavior Each unchanged message extra should be parsed once per Advanced Memory service lifetime and reused. Edited or deleted messages must invalidate or remove only their own cached entry. ## Actual behavior Every Advanced Memory context rebuild calls `object(message.extra)` for every stored message, even when the message metadata has not changed. A CPU profile of a large chat attributed roughly 209 seconds to this work and roughly 107 seconds to garbage collection during the captured interval. ## Steps to reproduce 1. Create or import a Roleplay or Game chat with a large stored-message history and Advanced Memory enabled. 2. Run repeated Advanced Memory operations or large generations without editing the historical messages. 3. Profile the server during context construction. 4. Observe repeated parsing of every message extra and associated allocation/GC work. ## Environment - Marinara Engine version: source checkout at the current `staging` baseline - Install type: Docker - OS + version: Linux 6.8.0-147-generic - Browser or app shell: not collected ## Logs, screenshots, or video The local CPU profile showed repeated `object(message.extra)` parsing as the primary Advanced Memory context-construction cost. No user-authored prompt content is included. ## Additional context The proposed narrow fix is a chat/message cache keyed by the raw stored `extra` value, with pruning for deleted messages and a regression covering reuse and targeted invalidation. I could not assign this issue to the authenticated GitHub account. @SpicyMarinara, please assign an owner if needed. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-11-07 16:42:52 +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#8423
No description provided.