Skip to content

Perf pass: memory-server query/write-path fixes #528

Closed

Description

@currentbits

From perf audit (thread 693440a8):

  • Add index on mentions(entity_id) — graphSearch full-scans per request
  • memory.js applyTokenBudget: precompute row costs instead of O(n^2) JSON.stringify
  • Hoist McpServer construction out of per-POST handler in index.js (rebuilt per request)

Activity

  1. currentbits commented on Aug 18, 2026

    @currentbits
    OwnerAuthor

    Done on branch coder/i-want-you-to-do-a-performance-pass-we-h-693440:

    • idx_mentions_entity ON mentions(entity_id) — graphSearch/janitor no longer full-scan mentions per request
    • applyTokenBudget precomputes per-row stringified costs (O(n^2) -> O(n)); char accounting reproduces estimateTokens(JSON.stringify(...)) exactly
    • MCP hoist REJECTED with evidence: @modelcontextprotocol/sdk 1.12 Protocol.connect asserts a single transport per Server, so a shared McpServer cannot serve concurrent stateless requests. Per-request buildServer (index.js:663) is the documented stateless pattern; its cost is tool registration only.

    Deferred: findNearDup re-tokenizing 500 bodies per store (needs persisted token sets/shingles), citation verifyAndHeal file-read cache, db.prepare statement cache, agent_trust GROUP BY TTL, vector scan at scale (sqlite-vec).

    Verified: memory suite green.

  2. added
    plan:done
    and removed
    plan:todo
    on Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions