perf: skip db writes for non-terminal status events#22085
perf: skip db writes for non-terminal status events#22085Algorithm5838 wants to merge 1 commit intoopen-webui:devfrom
Conversation
👋 Welcome and Thank You for Contributing!We appreciate you taking the time to submit a pull request to Open WebUI!
|
|
I like |
|
@Algorithm5838 @Classic298 tested? |
|
@tjbck let me test real quick |
|
Could cause side effects with custom function when the perf enhancements are minimal. Thanks for the contribution regardless. |
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
Every status event during streaming ("Thinking...", "Searching web...", etc.) calls
add_message_status_to_chat_by_id_and_message_id, which does a full read-modify-write of the chat JSON blob. A typical tool-use response triggers 5-15 of these for states that are only shown live during streaming.The client already gets these via the socket emit before the DB call, so the live UI is unaffected. The only status that matters for the persisted
statusHistoryis the finaldone=Trueone, which the frontend uses to render the collapsed summary after streaming (e.g. "Searched 3 sites").This adds a
doneguard so only terminal statuses hit the DB. Intermediate ones stay socket-only.Added
Changed
socket/main.py: guard status DB write withevent_data.get("data", {}).get("done", False)Deprecated
Removed
Fixed
Security
Breaking Changes
Additional Information
Screenshots or Videos
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.
Note
Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.