Skip to content

perf: memoize satellite-connector binary-path probes (#448)#459

Merged
tcconnally merged 1 commit into
mainfrom
perf/448-connector-probe-cache
Jun 25, 2026
Merged

perf: memoize satellite-connector binary-path probes (#448)#459
tcconnally merged 1 commit into
mainfrom
perf/448-connector-probe-cache

Conversation

@tcconnally

Copy link
Copy Markdown
Collaborator

Addresses #448's binary-probe half (the per-call subprocess re-probing).

Problem

memory_mesh, memtrace, and vaultmem each re-resolved their CLI binary on every call by running a --version subprocess against several candidate paths — and the resolvers are called per query / per repo / per project. vaultmem's fallback runs npx -y vault-mem-mcp --version, which can hit the npm registry (10s timeout), and was invoked on the availability check and once per project per render (≥ 1 + N probes).

Fix

Memoize each resolver's result per process — including the not-installed result (the common case in most environments), so a missing binary is probed once instead of on every call. _vaultmem_binary splits into a cached wrapper + _vaultmem_binary_uncached. conftest clears the three caches between tests so a test mocking the binary present/absent isn't served a stale result.

Deferred (the larger half of #448)

Reusing a persistent MCP subprocess across queries instead of spawn + handshake + teardown per call (template: MimirConnector's persistent Popen singleton). That needs the real external binaries to integration-test — left as follow-up.

Tests

New test_connector_binary_cache.py: memtrace probe runs once then caches (positive); a not-installed result is cached (no re-probe); memorymesh + vaultmem both memoize their None result. 3 passed.

🤖 Generated with Claude Code

Addresses #448's binary-probe half (the per-call subprocess re-probing).

memory_mesh, memtrace, and vaultmem each re-resolved their CLI binary on every
call by running a `--version` subprocess against several candidate paths — and
the resolvers are called per query / per repo / per project. vaultmem's fallback
runs `npx -y vault-mem-mcp --version`, which can hit the npm registry (10s
timeout), and was invoked on the availability check AND once per project per
render (≥ 1 + N probes).

Memoize each resolver's result per process — including the not-installed result,
which is the common case in most environments, so a missing binary is probed
once instead of on every call. (_vaultmem_binary splits into a cached wrapper +
_vaultmem_binary_uncached.) conftest clears the three caches between tests so a
test mocking the binary present/absent isn't served a stale result.

Deferred (the larger half of #448): reusing a persistent MCP subprocess across
queries instead of spawn + handshake + teardown per call (template:
MimirConnector's persistent Popen singleton). That needs the real external
binaries to integration-test and is left as follow-up.

Tests (new test_connector_binary_cache.py): memtrace probe runs once then caches
(positive), a not-installed result is cached (no re-probe), and memorymesh +
vaultmem both memoize their None result. 3 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tcconnally tcconnally merged commit 9ddf290 into main Jun 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant