mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-08 21:09:41 -05:00
[PR #23370] [MERGED] perf: replace JSON.stringify equality with fast-deep-equal #27170
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/23370
Author: @Algorithm5838
Created: 4/3/2026
Status: ✅ Merged
Merged: 4/17/2026
Merged by: @tjbck
Base:
dev← Head:perf/fast-deep-equal📝 Commits (1)
2aa7328perf: replace JSON.stringify equality with fast-deep-equal📊 Changes
6 files changed (+10 additions, -8 deletions)
View changed files
📝
package-lock.json(+1 -1)📝
package.json(+1 -0)📝
src/lib/components/chat/Messages/MultiResponseMessages.svelte(+2 -1)📝
src/lib/components/chat/Messages/ResponseMessage.svelte(+2 -1)📝
src/lib/components/chat/Messages/ResponseMessage/StatusHistory.svelte(+2 -4)📝
src/lib/components/chat/Messages/UserMessage.svelte(+2 -1)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request.
This is to ensure large feature PRs are discussed with the community first, before starting work on it. If the community does not want this feature or it is not relevant for Open WebUI as a project, it can be identified in the discussion before working on the feature and submitting the PR.
Before submitting, make sure you've checked the following:
devbranch. PRs targetingmainwill be immediately closed.devto ensure no unrelated commits (e.g. frommain) are included. Push updates to the existing PR branch instead of closing and reopening.Changelog Entry
Description
12 places in the codebase use
JSON.stringifyto compare objects for equality. This PR addresses the 5 in the message rendering and status pipeline.JSON.stringifyhas to serialize both sides in full before comparing, even if they differ on the first key.fast-deep-equalexits on the first mismatch and is 10-56x faster. There are also correctness edge cases:JSON.stringify(NaN) === JSON.stringify(null)returnstrue.The highest-impact changes are the slow-path comparisons in
ResponseMessage.svelte,UserMessage.svelte, andMultiResponseMessages.svelte. The fast-path (content/donechecks) from #21884 and #22098 is untouched.Added
fast-deep-equaldependencyChanged
JSON.stringifyequality comparisons withfast-deep-equalinResponseMessage.svelte,UserMessage.svelte,MultiResponseMessages.svelte, andStatusHistory.svelte.lengthpre-check inStatusHistorysinceequalcovers it internallyDeprecated
Removed
Fixed
Security
Breaking Changes
Additional Information
Starting with the message rendering pipeline since those are the most frequently executed paths. If this direction is acceptable, the remaining 7 call sites in
Chat.svelte,ModelSelector.svelte,RichTextInput.svelte, andNoteEditor.sveltecan follow in a separate PR.Screenshots or Videos
Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.