memorix icon indicating copy to clipboard operation
memorix copied to clipboard

CLI memory search stays alive for tens of seconds after printing results

Open RaviTharuma opened this issue 3 months ago • 2 comments

Description

memorix memory search "<query>" prints results (or "No memories found") and then the Node process stays alive for ~90s at high CPU. The CLI is unusable as a one-shot tool.

Root cause: prepareSearchIndex → hydrateIndexForStartup started attachCachedVectors in the background. That keeps the event loop alive while the 305MB JSONL cache is parsed and ~27k Orama documents are updated.

A later skipCachedVectors flag was added for CLI reads but inverted: deferCachedVectors: !options.skipCachedVectors made skipCachedVectors: true await getCachedEmbeddings() on the CLI thread.

Steps to Reproduce

  1. Large store + JSONL embedding cache present.
  2. From a git project: time memorix memory search "anything" --limit 3 --quality fast
  3. Observe: text is printed, then 15–90s more CPU before exit.

Expected Behavior

One-shot CLI search hydrates a lexical index, prints, exits. No JSONL parse, no background vector attach holding the process.

Actual Behavior

1.6.0: ~90s hang after print. After an inverted skip flag: still a synchronous cache load. Correct skip + no eager cache load on allowNetworkProbe: false brings exit down to the corpus loadAll() cost (~15s on 44k rows), which is a separate issue.

Environment

  • Memorix 1.6.0
  • macOS, 44k observations, 305MB JSONL cache

Additional Context

Fix commits are on #214 (dd859f5). CLI store/search still pays a ~15–28s loadAll(); tracked separately.

Related: #27, #214.

RaviTharuma avatar Aug 17 '26 13:08 RaviTharuma

Fix is in PR https://github.com/AVIDS2/memorix/pull/214 — not on main yet, so leaving this issue open until that PR merges.

Relevant work:

  • 13142d320f — one-shot CLI search skips cached-vector attach (skipCachedVectors was inverted and loaded the JSONL cache synchronously)
  • Files: src/cli/commands/operator-shared.ts

RaviTharuma avatar Aug 17 '26 16:08 RaviTharuma

Fixed by #214 and released in v1.6.2. One-shot CLI search avoids the long-lived cached-vector/background work that kept the process open after output. Closing as shipped.

AVIDS2 avatar Aug 18 '26 10:08 AVIDS2