[GH-ISSUE #2878] [Issue]: Streaming responses cause GUI lag during generation (per-token markdown re-parse) #1461

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

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

Originally assigned to: @Romuromylus on GitHub.

Summary

With streaming responses enabled, the entire live message's markdown is re-parsed on every streamed token, which makes the UI lag and stutter while a response is generating — and gets worse the longer the message.

Expected behavior

Streaming a long response should stay responsive; the cost of rendering each token should not grow with the length of the message already received.

Actual behavior

While a streamed response is generating, the UI becomes laggy/unresponsive (input lag, scroll stutter). The effect is most noticeable on long multi-paragraph responses and on setups running the server and browser on the same machine.

Steps to reproduce

  1. Enable streaming responses (Chat Settings → Responses → Enable streaming responses).
  2. Generate a long (multi-paragraph) reply.
  3. Observe input lag / scroll stutter while the tokens stream in.

Environment

  • Marinara Engine version: 2.0.5
  • Install type: source
  • OS + version: reported on Windows 11
  • Browser or app shell: Firefox

Logs, screenshots, or video

Reported as intermittent and hard to pin down ("the GUI is laggy/unresponsive can mean a lot of things"), but the streaming-token render path has a concrete, reproducible cost.

Additional context

Root cause: the live streaming message re-runs renderMarkdownBlocks over the full accumulated buffer on every token. Each token triggers a re-render of the message content, and the markdown renderer re-parses the entire string (multiple regex passes line-by-line plus recursive inline parsing) from scratch each time, so the work grows roughly O(n²) with the message length. Memoizing the parsed markdown so it is only recomputed when the content actually changes removes the per-token re-parse. This is one identified, deterministic contributor to the reported streaming lag.

Relevant files: packages/client/src/components/chat/ConversationMessageShared.tsx (MessageContent / renderTextBlock), packages/client/src/lib/markdown.tsx (renderMarkdownBlocks), packages/client/src/stores/chat.store.ts (per-token setStreamBuffer).

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (Jun 25, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2878 Originally assigned to: @Romuromylus on GitHub. ## Summary With streaming responses enabled, the entire live message's markdown is re-parsed on every streamed token, which makes the UI lag and stutter while a response is generating — and gets worse the longer the message. ## Expected behavior Streaming a long response should stay responsive; the cost of rendering each token should not grow with the length of the message already received. ## Actual behavior While a streamed response is generating, the UI becomes laggy/unresponsive (input lag, scroll stutter). The effect is most noticeable on long multi-paragraph responses and on setups running the server and browser on the same machine. ## Steps to reproduce 1. Enable streaming responses (Chat Settings → Responses → Enable streaming responses). 2. Generate a long (multi-paragraph) reply. 3. Observe input lag / scroll stutter while the tokens stream in. ## Environment - Marinara Engine version: 2.0.5 - Install type: source - OS + version: reported on Windows 11 - Browser or app shell: Firefox ## Logs, screenshots, or video Reported as intermittent and hard to pin down ("the GUI is laggy/unresponsive can mean a lot of things"), but the streaming-token render path has a concrete, reproducible cost. ## Additional context Root cause: the live streaming message re-runs `renderMarkdownBlocks` over the full accumulated buffer on every token. Each token triggers a re-render of the message content, and the markdown renderer re-parses the entire string (multiple regex passes line-by-line plus recursive inline parsing) from scratch each time, so the work grows roughly O(n²) with the message length. Memoizing the parsed markdown so it is only recomputed when the content actually changes removes the per-token re-parse. This is one identified, deterministic contributor to the reported streaming lag. Relevant files: `packages/client/src/components/chat/ConversationMessageShared.tsx` (`MessageContent` / `renderTextBlock`), `packages/client/src/lib/markdown.tsx` (`renderMarkdownBlocks`), `packages/client/src/stores/chat.store.ts` (per-token `setStreamBuffer`). ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:35:48 +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#1461
No description provided.