How duplicate chunks and broken caching made local RAG take 291 seconds per query
A developer building an offline RAG desktop app on llama.cpp discovered their system was taking nearly five minutes to answer simple questions across a nine-file project. Investigation revealed two root causes: duplicate chunks from mismatched lexical and vector search indexes were sending roughly 9,000 redundant tokens per query, and a misconfigured prompt cache was resetting to near-zero reuse because service calls shared the same slot as conversations. Fixing deduplication and splitting cache slots into separate pools for service calls and conversations pushed cache hit rates from 0% to 45–48%, dramatically cutting prefill costs. The developer also introduced a tiered response strategy: lightweight structured summaries generated once at import for broad questions, and narrow vector retrieval reserved for specific lookups. The key insight was that prefill is not a cost that can be eliminated, only reduced by ensuring the model reads less redundant content per query.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in