Summary
The Ollama embedder probes embedding dimensions by making a full embed API call on every mctl serve and mctl up invocation. Cache the discovered dimensions to eliminate 100-400ms of startup latency.
Context
In internal/embedder/ollama.go, NewOllamaEmbedder() calls probeDimensions() which sends a POST to /api/embed with a probe text just to discover the output vector size. This happens every time the embedder is initialized, adding 100-400ms to cold start. The dimensions for a given model are constant and don't need re-probing.
Key files:
internal/embedder/ollama.go — NewOllamaEmbedder(), probeDimensions() (line ~113)
internal/manifest/manifest.go — manifest config where dimensions could be stored
internal/lockfile/lockfile.go — lockfile metadata where dimensions could be cached
Acceptance Criteria
Technical Approach
- After
probeDimensions(), store the result in lockfile [meta] section (e.g., embedding_dimensions = 1024) or a separate cache file at ~/.mycelium/cache/ollama-dims.json
- On startup, check cache first: if model name matches and dimensions are cached, skip probe
- If model name differs or cache is missing, probe and update cache
- Lockfile approach is simpler (already read on startup); cache file approach is more decoupled
Dependencies
None — standalone improvement.
Out of Scope
- Caching Ollama model availability checks (
checkModelAvailable)
- Other embedder initialization optimizations
Summary
The Ollama embedder probes embedding dimensions by making a full embed API call on every
mctl serveandmctl upinvocation. Cache the discovered dimensions to eliminate 100-400ms of startup latency.Context
In
internal/embedder/ollama.go,NewOllamaEmbedder()callsprobeDimensions()which sends a POST to/api/embedwith a probe text just to discover the output vector size. This happens every time the embedder is initialized, adding 100-400ms to cold start. The dimensions for a given model are constant and don't need re-probing.Key files:
internal/embedder/ollama.go—NewOllamaEmbedder(),probeDimensions()(line ~113)internal/manifest/manifest.go— manifest config where dimensions could be storedinternal/lockfile/lockfile.go— lockfile metadata where dimensions could be cachedAcceptance Criteria
Technical Approach
probeDimensions(), store the result in lockfile[meta]section (e.g.,embedding_dimensions = 1024) or a separate cache file at~/.mycelium/cache/ollama-dims.jsonDependencies
None — standalone improvement.
Out of Scope
checkModelAvailable)