Medium: tag-only model checks serially fetch metadata for every installed Ollama model
Severity
Medium / admission latency — the tag-only list_installed() operation issues an Ollama show(model) call for every installed model, even when the caller only needs the set of model names. A slow or busy Ollama instance with a large library can delay every new generation before the user's message is admitted.
Source evidence
services/models.py:130–155:ModelService.list_installedcallslist_installed_details(), which callsinventory(). The latter serially invokes_with_show_details(item)for every model.services/models.py:358–421: each_with_show_detailsseparately calls the liveshow(model)API.services/model_catalog.py:45–61: the combined GGUF+Ollama catalog's tag-onlylist_installedalso goes through the full metadata inventory.api/routes.py:473–493: generation admission callsdeps.models.list_installed()before preparing the prompt / saving the turn. The expensiveshowcalls are not required to validate the exact selected tag.ModelService.check()already uses the cheaperextract_model_tags(gateway.list())for tag-only checks (models.py:170–176), showing this behavior is avoidable.
Deterministic performance reproduction
- Supply a fake Ollama gateway with 80 installed tags;
list()returns them immediately, and eachshow(model)sleeps 100 ms before returning metadata. - Call
CombinedModelCatalog.list_installed()once. - Actual: one
list()and 80 serialshow()calls, adding roughly 8 seconds to an operation intended to retrieve names only. A new chat generation waits in admission for this work. - Expected: one
list()plus the bounded GGUF filename scan, no per-model details query on the hot path; richshowmetadata remains available throughinventory()for Settings.
Fix and regression
Separate a fast ModelService.list_installed that extracts tags from one list() response from the optional UI metadata-enrichment path. Make the combined catalog union these tags with GGUF names, without invoking expensive Ollama show(). Add a fake-gateway call-count test asserting zero show calls for tag-only checks and one-per-model only for deliberate details retrieval. Consider caching rich metadata between inventory polls as a follow-up.
Reviewed revision: e824fe2dcba0d1be127c9fff165f776186dc37e9. Deterministic call graph; timing benchmark/integration test not executed.