mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-08 21:09:41 -05:00
[PR #21884] [MERGED] perf: fast-path comparison in ResponseMessage to skip JSON.stringify during streaming #49369
Reference in New Issue
Block a user
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?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/21884
Author: @Classic298
Created: 2/25/2026
Status: ✅ Merged
Merged: 2/26/2026
Merged by: @tjbck
Base:
dev← Head:perf/response-message-fast-compare📝 Commits (1)
28effdfperf: fast-path comparison in ResponseMessage to skip JSON.stringify during streaming📊 Changes
1 file changed (+10 additions, -2 deletions)
View changed files
📝
src/lib/components/chat/Messages/ResponseMessage.svelte(+10 -2)📄 Description
ResponseMessage compared the entire message object via JSON.stringify on every reactive tick to detect changes. During streaming, content changes on every token, making the two O(content_length) JSON.stringify calls always return different results — pure wasted work. Add a fast O(1) comparison on content and done fields first. When either differs (the common streaming case), skip straight to cloning. Only fall through to the expensive JSON.stringify comparison for infrequent changes like sources, annotations, or status updates.
this is a completely invisible change - free lunch
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.