mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 03:18:23 -05:00
[PR #22299] [CLOSED] perf: replace O(n*m) custom model matching with O(n+m) dict lookups #42228
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/22299
Author: @Classic298
Created: 3/6/2026
Status: ❌ Closed
Base:
dev← Head:perf/dict-lookup-custom-models📝 Commits (3)
50e2af7perf: replace O(n*m) custom model matching with O(n+m) dict lookups79d308cperf(models): use dict lookups for custom-to-base model matching1e22b92Merge branch 'perf/dict-lookup-custom-models' of https://github.com/Classic298/open-webui into perf/dict-lookup-custom-models📊 Changes
1 file changed (+64 additions, -48 deletions)
View changed files
📝
backend/open_webui/utils/models.py(+64 -48)📄 Description
The custom model matching loop in get_all_models() iterated all base models for every custom model, resulting in O(n*m) complexity. This also rebuilt a list of model IDs per custom model in the elif branch.
Replace the nested loops with two dict indices (exact ID and Ollama base-name) built once, then look up each custom model in O(1). Also replace the per-iteration list comprehension for existing model IDs with a precomputed set.
Behavior is identical - same matching logic, same precedence.
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.