mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-26 03:14:08 -05:00
[PR #22105] [CLOSED] perf: cache marked.lexer() calls for alert and details block content #81361
Reference in New Issue
Block a user
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/22105
Author: @Classic298
Created: 3/1/2026
Status: ❌ Closed
Base:
dev← Head:perf/cache-sublexer-calls📝 Commits (1)
c00d3a4perf: cache marked.lexer() calls for alert and details block content📊 Changes
2 files changed (+17 additions, -3 deletions)
View changed files
📝
src/lib/components/chat/Messages/Markdown/AlertRenderer.svelte(+15 -1)📝
src/lib/components/chat/Messages/Markdown/MarkdownTokens.svelte(+2 -2)📄 Description
alertComponent() and the details block renderer both call marked.lexer() inline during rendering. Since these run inside {#each tokens} loops, they re-lex on every render cycle even when the text content hasn't changed. Add a simple text-keyed cache (capped at 100 entries) that returns cached tokens for unchanged text, avoiding redundant parsing during streaming.
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.