mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2531] [Issue]: SplitMessageGroup is not memoized — re-renders ~60x/sec during streaming #1258
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#1258
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 9, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2531
Originally assigned to: @Romuromylus on GitHub.
Summary
Severity: Low — performance (client render).
SplitMessageGroupis not memoized but receives the per-tokenstreamBuffer/thinkingBufferprops, so every split assistant message currently mounted re-runs its function body ~60×/sec for the full duration of every generation. The sibling rendererConversationMessageis alreadymemo-wrapped and bails out correctly.Expected behavior
SplitMessageGroupshould be wrapped inReact.memo(likeConversationMessage) and only receive the streaming buffers when it is actually the regenerating group, so non-regenerating groups have stable props and skip re-render during streaming.Actual behavior
packages/client/src/components/chat/ConversationView.tsx:1195definesSplitMessageGroupas a plain function component with nomemo, and the render site (:1018-1024) hands itstreamBuffer={streamBuffer}andthinkingBuffer={thinkingBuffer}:ConversationViewsubscribes tostreamBuffer/thinkingBuffer(:351-352), and the typewriter loop callssetStreamBufferonce perrequestAnimationFrame(use-generate.ts:888/903) → ~60 updates/sec during streaming. Every mountedSplitMessageGroup(up toMAX_MOUNTED_TRANSCRIPT_MESSAGES = 160; multi-line assistant replies are split into groups very commonly in roleplay) re-executes its body each frame (recomputingfullContent = items.map(gi => gi.msg.content).join("\n")at:1233) even though only the regenerating group uses those buffers (theisRegenbranch,:1316-1379). The innerConversationMessagechildren still memo-bail, so this is bounded per-frame parent-body work + reconciliation, not a full subtree re-parse — hence Low.Steps to reproduce
SplitMessageGroup).ConversationViewre-renders ~60×/sec and everySplitMessageGroupre-executes its body each frame because it is not memoized and itsstreamBuffer/thinkingBufferprops change every token.Environment
staging @ a9fdae8)Logs, screenshots, or video
Static source audit, cited to file:line above.
Additional context
Fix: wrap
SplitMessageGroupinReact.memo(mirroringConversationMessage.tsx:332). To make the memo effective, only feedstreamBuffer/thinkingBufferto aSplitMessageGroupwhen it is the regenerating group (regenerateMessageId === items[0].msg.id); pass empty strings / omit otherwise so non-regenerating groups have stable props and bail. TheisRegenbranch (:1316-1379) is the only place those buffers are used.The payoff is modest because the inner children already memo-bail — filing as a low-priority render cleanup.
Regression notes: found via static audit;
main(65a0395) has the byte-identical structure (SplitMessageGroupa plain function fedstreamBuffer,ConversationMessagememoized), so this is a shared pre-existing pattern, not amain→stagingregression.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: