memorix icon indicating copy to clipboard operation
memorix copied to clipboard

Cached-vector attach starves MCP initialize; OpenCode marks memorix failed

Open RaviTharuma opened this issue 3 months ago • 2 comments

Description

After HTTP is up and /health is green, attachCachedVectors updates tens of thousands of Orama documents with 1024-d vectors on the same event loop. Yields every 10/50 updates are not enough: the process sits at 60–70% CPU for many minutes.

MCP initialize then accepts the TCP connection but writes 0 bytes for 20s. OpenCode mcp list reports:

✗ mcpm_memorix failed
   http://127.0.0.1:3211/mcp

even though the config is correct and /health returns ok.

Steps to Reproduce

  1. Start serve-http on a 40k+ store with a warm JSONL cache.
  2. Trigger runtime init (memorix_session_start or any non-bootstrap tool).
  3. While CPU is high, POST MCP initialize with a 15–20s timeout, or run opencode mcp list.

Expected Behavior

initialize stays ~50–200ms during vector attach. OpenCode shows mcpm_memorix connected. Attach continues in the background.

Actual Behavior

curl /mcp initialize timed out at 20s with 0 bytes while /health still succeeded. After attach finished, initialize worked. OpenCode had already marked the server failed.

Environment

  • Memorix 1.6.0
  • MacBook 13, ~52k observations, 27,320 cached vectors
  • OpenCode remote MCP http://127.0.0.1:3211/mcp

Additional Context

#214 now setImmediates every attach and setTimeout(10) every 25 updates. After that change: initialize during attach was 0.043s, and OpenCode showed ✓ mcpm_memorix connected.

Related: HTTP wedge issue, #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:

  • 01763fa1ee — Orama cached-vector attach yields so MCP initialize stays ~50ms instead of starving the event loop
  • Files: src/store/orama-store.ts, src/embedding/api-provider.ts

RaviTharuma avatar Aug 17 '26 16:08 RaviTharuma

Fixed by #214 and released in v1.6.2. Cached-vector attachment moved off the MCP initialize critical path; OpenCode can complete initialization while recovery continues in the background. Closing as shipped.

AVIDS2 avatar Aug 18 '26 10:08 AVIDS2