Files
open-webui/backend/open_webui/utils
Classic298 243a39dc9d perf: read the model pool with one HGETALL instead of one HGET per model (#27821)
`request.app.state.MODELS` is a `RedisDict` when Redis is configured. Unpacking it with `{**pool}` makes Python call `keys()` and then `__getitem__` once per key, which is one HKEYS plus one HGET per model, issued sequentially through a synchronous client. At 200 models that is 201 blocking Redis round trips per call.

`RedisDict.items()` is a single HGETALL, so `dict(pool.items())` fetches the same data in one round trip. `utils/chat.py:184` already does exactly this and carries a comment explaining why; these ten call sites were missed.

They are on the direct-connection branch of the task endpoints (title, tags, follow-up, autocomplete, query generation and the rest), of `chat_completed`, and of context compaction, so they run for background tasks fired on ordinary chat turns.

Behaviour is unchanged. The merged mapping is identical, the explicitly added direct model still overrides any pool entry with the same id, and when Redis is not configured the pool is a plain dict where `dict(d.items())` and `{**d}` are equivalent.

It also closes a race. `RedisDict.set` writes with HSET and then HDELs the stale keys, so a key returned by HKEYS could be deleted before its HGET arrived, raising `KeyError` out of the dict literal and failing the request mid model refresh. The old path could likewise observe a mix of pre- and post-refresh entries. HGETALL is atomic, so the caller now always sees one coherent snapshot.
2026-07-31 17:25:53 -04:00
..
2026-07-27 04:27:13 -04:00
2026-07-01 02:48:29 -05:00
2026-06-29 11:56:00 -05:00
2026-07-27 03:01:19 -04:00
2026-07-23 22:52:23 -04:00
2026-07-27 19:24:03 -04:00
2026-07-27 03:54:05 -04:00
2026-03-17 17:58:01 -05:00
2026-07-23 02:54:56 -04:00
2026-07-26 21:12:14 -04:00
2026-07-24 01:44:30 -04:00
2026-07-27 03:05:26 -04:00
2026-07-23 21:29:33 -04:00
2026-07-27 02:36:15 -04:00
2026-07-27 00:12:47 -04:00
2026-07-27 02:24:41 -04:00
2026-07-27 19:39:36 -04:00
2026-07-27 02:49:08 -04:00
2026-07-26 23:09:22 -04:00
2026-07-27 19:39:36 -04:00
2026-07-27 19:39:36 -04:00
2026-07-23 19:17:19 -04:00
2026-03-17 17:58:01 -05:00
2026-07-27 04:17:00 -04:00
2026-07-20 22:11:42 -04:00
2026-06-19 00:16:06 +02:00
2026-07-10 18:32:21 -05:00
2026-07-27 03:41:08 -04:00
2026-07-27 19:39:36 -04:00
2026-06-29 12:29:10 -05:00
2026-07-27 19:39:36 -04:00