perf: stop the ollama health probe fetching /api/tags twice per poll - #491
Merged
Conversation
The integrations-health probe read the installed model list for its badges, then reset the vision cache and called resolve_vision_model, which fetched the identical /api/tags payload again via installed_models. The Settings page polls that endpoint every 8 seconds, so every poll cost two identical GETs, forever, for data already in hand. resolve_vision_model now accepts an optional installed list and the probe passes the names it just derived. Behaviour is unchanged in both directions: the cache is still reset on each poll, so a model pulled outside subarr is still noticed, and any caller that passes nothing still fetches exactly as before, which is why the existing vision suite needed no edits. The test asserts the probe issues exactly one GET /api/tags while still resolving the vision model, pinning the cost and the behaviour together so neither can regress alone. Confirmed red first, reporting ['/api/tags', '/api/tags', '/api/version'] Full suite: 1985 passed, 6 skipped. ruff check and format clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Spotted from the ollama side:
subarr-nextwas hitting/api/tagsfar more often than the poll interval alone explains. It is not one call per poll, it is two.The defect
reset_vision_cache()'s own docstring says it is for "Settings save + model-pull completion". The health probe is neither, so it invalidated the cache on every poll and the resolver re-fetched what the probe was already holding. Settings polls every 8s, so the cost per poll was 2x/api/tagsplus 1x/api/version, indefinitely.The fix
resolve_vision_model()takes an optionalinstalledlist; the probe passes the names it just derived from its owntags()call.Behaviour is deliberately unchanged in both directions:
test_vision_capability.pysuite needed no edits at allSimply dropping the
reset_vision_cache()call would have been a smaller diff but would have stopped noticing externally pulled models, so it was rejected.Verification
The test pins the cost and the behaviour together, so neither can regress on its own: it asserts exactly one
GET /api/tagsand that the vision model still resolves.Confirmed red before the fix, for the right reason:
ruff checkandruff format --checkclean