superlocalmemory icon indicating copy to clipboard operation
superlocalmemory copied to clipboard

4.2.11: every explicit recall exceeds its run budget (503 RECALL_BUSY) on a 37k-fact store with 3.6M edges; 4.1.24 answers the same store in 1.1–1.5 s

Open raorthopro-cpu opened this issue 1 month ago • 4 comments

Environment

  • macOS (Apple Silicon), superlocalmemory installed globally via npm, daemon run by launchd (unified_daemon --start --port=8768), Python 3.14 venv created by the package.
  • Mode B (local Ollama gemma3:4b), entity_compilation_enabled: false, forgetting.scheduler_interval_minutes: 43200, Laya declined (db/runtimes/laya/declined).
  • Store: 37,129 facts, 6,285 entities; adjacency cache "34711 nodes, 3579356 edges"; projection outbox depth ≈ 21,000 (behind: true); Lance semantic projection diverged from SQLite on sampled check 1 of 1 searches; using SQLite.
  • Upgrade path: 4.1.24 → 4.2.11 (npm install -g), two attempts on 2026-10-27, both rolled back to 4.1.24 + database backup.

What happens Every explicit /recall returns HTTP 503 after exactly 18.0 s:

{"ok":false,"code":"RECALL_BUSY","retryable":true,"retry_after_s":2,"error":"SuperLocalMemory is answering other questions right now. Ask again in about 2 seconds; nothing was lost."}

daemon-error.log of the second attempt (local time):

06:53:22 [slm] upgraded 4.1.24 → 4.2.11 ...
06:53:36 migrations applied: ['M055_learning_attribution']   (M062/M064/M065/M066 reported; M067 not named in the log)
06:54:00 BackendOrchestrator: daemon ready (cozo=active, lancedb=active, queued=21033)
06:54:06 Loaded adjacency cache: 34711 nodes, 3579356 edges, 6285 entity mappings for profile default
06:54:10 Lance semantic projection diverged from SQLite on sampled check 1 of 1 searches; using SQLite
06:55:03 Explicit recall overran its run budget; reporting busy
06:55:11 Channel semantic did not finish within 8.0s; this recall is answering without it
06:55:11 Channel hopfield did not finish within 8.0s; ...
06:55:11 Channel spreading_activation did not finish within 8.0s; ...
06:58:07 Spreading-activation graph pre-warmed for profile default
06:58:31 vector store compacted: 211 versions -> 1
07:00:03 Memory watchdog: killing Python (PID 64932, 2927 MB > 2500 MB limit)
07:00:03 Graph metrics at startup: graph metrics for default FAILED: graph metrics process failed: RuntimeError: background process ended without a result
07:01:16 memory store checked in 234 s: 766 item(s) to repair
07:01:18 … 07:10:22 Explicit recall overran its run budget; reporting busy   (every explicit recall, 18 s apart)

After launchctl kickstart -k (fresh daemon, no concurrent requests):

07:12:45 Recall engine pre-warmed in 47236ms
07:13:31 Explicit recall overran its run budget; reporting busy

/health at that point: ready: true, recall_warmup: {"phase":"warm","warm":true}, recall_health.recall_healthy: true. A SIGUSR1 thread dump while idle showed every worker thread waiting (no recall in flight); daemon RSS ≈ 4.6 GB. In recall_core.py, EXPLICIT_CEILING_S = EXPLICIT_QUEUE_S + 3.0 + EXPLICIT_RUN_GRACE_S, and SLM_SEARCH_RECALL_TIMEOUT_S can only shorten the budget.

Same store on 4.1.24 (restored from backup, same machine, minutes later): /recall median 1,148 ms, max 1,443 ms (3 queries, limit 10).

Local modification (disclosed): to keep the laptop cool during the day we patch three loops so they take no new background work while a marker file exists: daemon/materializer.py (PendingMaterializer loop), core/projection_drain.py (_run, drain_once, claim_batch loop) and server/memory_health_service.py (can_work() → False). The projection drain was therefore paused during the test, which explains the outbox backlog and the Lance divergence. The equivalent patch (materializer loop in unified_daemon.py on 4.1.x) is active on 4.1.24, where recall is fast.

Questions

  1. Is the ~18 s explicit ceiling expected to be hit on a store of this size (3.6M edges, SQLite semantic fallback)? Is there a supported way to allow a longer explicit budget, or to have explicit recall degrade to the keyword fallback instead of returning 503?
  2. "Graph metrics at startup FAILED" after the memory watchdog killed the helper at 2.9 GB: is the 2,500 MB per-worker limit configurable, and does a failed metrics pass affect recall latency or ranking?
  3. Would draining the projection outbox (≈21k) before upgrading be required for 4.2.x recall to use Lance instead of SQLite?

Full daemon-error.log / daemon.json.log of both attempts are available on request. Related: #296 (fixed in 4.2.11 — thank you).

raorthopro-cpu avatar Oct 27 '26 06:10 raorthopro-cpu

Thank you for the detailed report and the log. It was a real regression, and you were right that retrying could never help.

Fixed in 4.2.12, which is being published now (PyPI and npm within the hour): pip install -U superlocalmemory or npm i -g superlocalmemory, then slm restart.

What was wrong: when an explicit recall ran past its time limit, the daemon answered 503 "busy, ask again in 2 seconds" even though no other recall was running. Each retry overran the same way. Separately, the semantic, hopfield and spreading-activation channels each ran the same nearest-neighbour search at the same moment, so on a large store three full vector scans competed on every recall. Those are exactly the three channels your log shows timing out.

What 4.2.12 does:

  • A recall that runs out of time answers with keyword matches, labelled retrieval_mode: degraded_lexical and unchecked, instead of 503. RECALL_BUSY is kept for when every slot really is taken, the one case where asking again helps.
  • The three channels share one vector scan.
  • The channel phase stops waiting before the caller gives up, so what finished still reaches the answer.

Measured on a copy of a 37k-fact store on one machine, 12 alternating questions: 4.2.11 averaged 12.1 s, peaked at 18.06 s and answered 3 of 12 with 503. 4.2.12 averaged 2.3 s, peaked at 3.6 s, and answered all 12 with full results.

To your other questions: the 2,500 MB watchdog limit is a floor; the global budget is 40% of RAM (global_rss_budget_mb in config, 0 = automatic). Whether a failed graph-metrics pass affects ranking I have not confirmed yet and will follow up here. Draining the projection outbox is not required for recall to work, but while Lance is behind, semantic search uses the slower SQLite path, so keeping the drain running will help latency. If you try 4.2.12 on your store, we'd like to hear the numbers.

varun369 avatar Oct 28 '26 06:10 varun369

Following up on the question I left open: does a failed graph-metrics pass affect ranking?

Yes, a little. PageRank and community scores from that pass feed the entity-graph and spreading-activation channels. A failed pass removes nothing: the scores from the last good pass stay in place, and facts added since then have no score until a pass succeeds. Besides the one-shot pass at startup, the metrics are recomputed in the regular maintenance cycle, which runs every forgetting.scheduler_interval_minutes. With yours at 43200, that is once every 30 days.

There is a second problem in your log, and it is ours: the memory watchdog killed the metrics helper at 2.9 GB against a 2.5 GB limit. On a graph of 3.6 million edges that will probably happen on every pass, so your metrics may never refresh. I'm treating that as a bug and will post here when the helper has a limit sized to the graph.

4.2.12 is now live on PyPI and npm. On this machine's store (38k facts) live recall went from a 12.1 s average with 503s to a 1.6 s average with none.

varun369 avatar Oct 28 '26 14:10 varun369

The watchdog problem I mentioned is fixed in 4.2.13. The graph-metrics helper now gets a memory limit sized to the graph: 800 MB plus about 1.2 KB per edge, never below the 2.5 GB worker default and never above the daemon's budget of 40% of RAM. For 3.6 million edges that comes to about 5.1 GB, as long as your RAM allows it. The limit applies only to that helper while it runs; every other worker keeps 2.5 GB.

With your maintenance interval at 43200 minutes, the next refresh after upgrading comes from the startup pass. That pass runs about two and a half minutes after the daemon starts whenever a visible memory has no score yet or the scores still cover memories that are gone, which is the case after your upgrade.

varun369 avatar Oct 28 '26 19:10 varun369

Thank you for the fast turnaround. Numbers from the same store on 4.2.13 (upgraded today from 4.1.24, projection outbox still ~11k behind while draining):

  • First measurement: every explicit recall still took exactly 18.0 s, now returning retrieval_mode: degraded_lexical with every channel reported timeout (bm25 and temporal included), on an idle daemon.
  • A thread dump at 6 s into a recall showed all slm-recall-channel_* workers idle and the recall thread in retrieval/community_context.py:59 build_community_context → read_connection_pool._run (recall-health stuck in the same place).
  • Cause: the erasure clause from storage/erasure_visibility._aggregate_clause — NOT EXISTS (SELECT 1 FROM json_each(fact_ids_json) member JOIN projection_tombstones pt ON pt.profile_id = … AND pt.fact_id = member.value). This store has 14 community summaries holding 110,830 fact ids in total and 1,885 tombstones. The planner picks idx_projection_tombstones_memory (profile_id, memory_id) (SEARCH pt USING INDEX … (profile_id=?)), so each of the 110k members probes all 1,885 tombstones: 6.5 s on a fresh read-only connection, longer inside the daemon.
  • With a composite index the same query takes 0.02 s (SEARCH pt USING COVERING INDEX … (profile_id=? AND fact_id=?)):
CREATE INDEX IF NOT EXISTS idx_hb_tombstones_profile_fact ON projection_tombstones(profile_id, fact_id);
ANALYZE projection_tombstones;

After adding it locally, explicit recall on the same store: 694 / 646 / 528 ms (median 698 ms, max 1.4 s over several runs) — faster than 4.1.24 here. It would be good to ship that index (or an equivalent plan) in a migration, since any store with large communities and a few tombstones hits this on every recall.

Also noted, for what it's worth: with ~21k outbox entries the drain ran at ≈1,500 entries/min on 4.2.13 (one core), versus ≈45/min we measured on 4.1.11 — the "one write per fact" change is very noticeable.

raorthopro-cpu avatar Oct 30 '26 18:10 raorthopro-cpu