mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2304] [Issue]: Streaming render storm — SplitMessageGroup defeats ConversationMessage memo, re-parsing the whole transcript ~22x/sec #1139
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1139
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?
Originally created by @Romuromylus on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2304
Originally assigned to: @Romuromylus on GitHub.
Summary
Severity: Medium — Performance.
SplitMessageGrouprebuilds a fresh combined message object on every render and passes it as themessageprop toConversationMessage(aReact.memowith the default shallow comparator). The new object reference always fails the memo, so during streaming — when the view re-renders ~22×/sec — every split assistant bubble in the mounted window re-runs its markdown parse/sanitize, even though only the streaming bubble's content actually changes.Expected behavior
Non-streaming message bubbles should not re-render (and re-parse markdown) on every streaming buffer commit. Only the bubble whose content is actively changing should re-render.
Actual behavior
ConversationViewsubscribes tostreamBuffer/thinkingBuffer(src/features/modes/conversation/components/ConversationView.tsx:408-409). The store commits the buffer every 45 ms (STREAM_BUFFER_COMMIT_INTERVAL_MS = 45,use-generate.ts:90) — ~22×/sec for the full duration of each generation — soConversationViewre-renders ~22×/sec.ConversationMessageismemo()with the default shallow comparator (ConversationView.tsx:338, no custom comparator).SplitMessageGroup(ConversationView.tsx:1435) is an unmemoized plain function invoked inline in the render loop (1251). On every render it builds a new object literal:The new
combinedMsgreference fails the child memo, forcing a re-render. The re-render is genuinely costly:MessageContent(180) is unmemoized and callsrenderMarkdownBlocks(a full line-by-line regex markdown→ReactNode parse,markdown.tsx:355) directly in its render body (214) with nouseMemo; therenderedContentmemo (484) only caches the macro-resolved string, not the markdown parse.In Discord-style conversation mode, multi-paragraph assistant replies are split into
__blockNgroups (817-843), so most visible bubbles route throughSplitMessageGroup. The mounted window holds up to 160 messages (MAX_MOUNTED_TRANSCRIPT_MESSAGES = 160), so the bulk of the transcript re-parses markdown ~22×/sec for the entire duration of every reply, scaling linearly with on-screen message count. The single-message path (1295-1318) passes the stablemsgreference, so its memo correctly bails — confirming the split-group path is the leak.Steps to reproduce
SplitMessageGroup-rendered bubble in the window re-renders/re-parses ~22×/sec, not just the streaming one.Impact area
Environment
47b16701Logs, screenshots, or video
Static source audit; claims cited to file:line above.
Regression notes
Found via static audit of the refactor branch; not verified against main.
Additional context
Suggested fix: wrap
SplitMessageGroupinReact.memoand memoizecombinedMsg/combinedContentwithuseMemokeyed onitems(only recompute when item ids/content change); memoizeMessageContentso the markdown parse only re-runs when content changes; and ideally gatestreamBuffer/thinkingBufferso non-streaming groups never receive live streaming props at all.Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:
@Romuromylus commented on GitHub (Jun 6, 2026):
Fixed by #2383, merged into
refactor(squash5781684d).