Files
open-webui/backend/open_webui
Classic298 ce22e0bb15 perf: stop rescanning the whole chat JSON on every streamed event write (#28820)
Every streamed event that persists to a chat (status updates, citations,
file attachments, message content) serialized the entire conversation JSON
three times: a null-byte check of the stored row, a second sanitize of the
whole blob after merging in the event payload and the flush of the UPDATE
itself. The middle pass rescans megabytes of already-clean history for null
bytes that can only come from the small incoming payload, so long chats pay
for their full history on every single event.

The write paths now sanitize just the incoming message, message id and
status dict and keep the row-level sanitize, so legacy rows with null bytes
still self-heal as before. Median per-event write time (sqlite, orjson):
1 MB chat 15.0 ms to 11.1 ms, 4 MB 65.2 ms to 52.4 ms, 10 MB 159.9 ms to
124.5 ms, roughly 20 percent less per event. As a side effect the
chat_message dual write now receives the sanitized message; previously null
bytes in non-content fields were cleaned in the blob but written raw to
chat_message, which failed that insert on PostgreSQL. Verified byte-identical
rows against the previous implementation across nine scenarios covering null
bytes in every input, legacy dirty rows, a missing title and a NULL chat
column.
2026-08-19 17:52:05 -07:00
..
2026-08-10 23:22:08 -06:00
2026-08-19 16:14:27 -07:00
2026-08-14 00:22:17 -06:00
2026-07-27 19:39:36 -04:00
2026-07-31 17:41:14 -04:00
2026-08-17 00:24:47 -07:00
2026-07-27 19:39:36 -04:00
2026-08-17 00:47:32 -07:00
2026-08-16 23:21:00 -07:00
2026-08-17 00:47:32 -07:00
2026-08-14 00:22:17 -06:00