Files
DeepTutor/deeptutor/services
Leveling 41fdf08b92 fix(rag): size the docstore count cache to the catalogue, not one KB (#2777)
A KB-list / get_info sweep probes every version-N directory of every KB,
because the UI renders readiness per version. The docstore count cache is
keyed per version directory, so its capacity has to cover the whole
catalogue, not a single KB's worth.

At the old fixed 128 slots a real installation (13 KBs, 310 version
directories -- #2772) exceeded the working set on every sweep: each probe
evicted exactly what it had just read, the hit rate stayed at a permanent
0%, and every UI navigation re-parsed every multi-MB docstore.json. On a
memory-constrained host that showed up as a pinned event loop and hundreds
of GB of disk reads.

Raise the capacity to 4096. Each entry is a path plus an int, so this costs
about a megabyte even well above the working set.

Reproduced against v1.7.3 with a fixture matching the report (13 KBs, 310
versions, 52 MiB of docstore.json), replaying inspect_kb_versions() per KB:

  before: 310 / 310 / 310 / 310 / 310 docstore parses per sweep, 0.0% hit rate
  after:  310 /   0 /   0 /   0 /   0 docstore parses per sweep, 100% warm

A rewritten docstore still invalidates correctly (doc_count 400 -> 1), and
unchanged versions stay cached. The new regression test builds 2 KBs x 100
versions, which is above the old cap, and fails on the unfixed code
(400 parses instead of 200).

Closes #2772
2026-11-30 23:21:42 +08:00
..
…
2026-11-16 02:17:36 +08:00
…