Skip to content

Vector sync re-prepares the whole oversized entity on every pass #1786

Closed

Description

@phernandez

Problem

Vector sync re-prepares an entire oversized entity on every pass, even though a pass embeds at most OVERSIZED_ENTITY_VECTOR_SHARD_SIZE (256) chunks (repository/semantic_vector_sync.py:29). Every pass rebuilds and hashes all of the entity's chunks first, so the cost of a pass grows with the note's size, not with what changed.

For a large note that keeps being edited, this repeats on every edit. The cost is note size times edit rate.

Evidence (Basic Memory Cloud production, 2026-10-11 to 10-18)

  • One 2.6 MB note with about 8,700 chunks and 3,400 observations was edited by an agent up to about 1,400 times a day.
    • Typical successful passes: 200 to 230 s of prepare, then 77 to 118 s of embedding. About 7,500 of 8,400 chunks were skipped as unchanged, and the pass ended with entities_deferred=1.
    • Over the week, vector sync on that one workspace used 115 worker-hours: 67 h of prepare, 15 h of embedding.
    • About 3,000 more attempts timed out about 32 s into the batch.
    • The "oversized entity" log fired about 700 times for that one note in 4 days.
  • Other workspaces have the same shape at smaller scale: a 25.5 MB note with 32.7k chunks, and an entity with 18k chunks.

Fix

Make a pass's cost scale with the chunks that changed, not with the whole entity. For example:

  • reuse the stored per-chunk source hashes, so unchanged chunks are not rebuilt and re-hashed every pass;
  • and/or debounce or coalesce embedding for very large entities that are edited constantly, so a burst of edits produces one pass instead of hundreds.

Acceptance

  • A test with an oversized entity, where one small edit triggers a pass, shows the prepare work bounded by the changed chunks, not by the entity's total chunk count.
  • Repeated edits to one oversized entity within the debounce window cause one embedding pass, not one per edit.

Activity

  1. added
    bug
    cost-review-2026-10
    on Oct 20, 2026
  2. claude commented on Oct 20, 2026

    @claude
    Contributor

    Claude finished @phernandez's task in 14s —— View job


    Triage

    • Type: Bug (performance and cost defect)
    • Priority: High. The production evidence shows one note using 115 worker-hours in a week, and other workspaces show the same pattern at smaller scale.
    • Component: Database/sync (vector sync in repository/semantic_vector_sync.py). It was observed in Cloud production, so I labeled it cloud.
    • Complexity: Medium to Complex. Reusing the stored per-chunk source hashes means changing how the prepare phase decides which chunks to rebuild. A debounce or coalesce for edits to the same large entity also needs a defined lifecycle.

    Duplicates and related issues

    I found no exact duplicate. These closed issues cover nearby ground and may help:

    Both cover embedding and shard resumption. This issue is about the prepare and hash cost that remains on every pass.

    Notes

    • The issue has an evidence section, a proposed fix, and acceptance criteria, so I don't need reproduction steps.
    • The two acceptance criteria are testable separately: prepare work bounded by changed chunks, and one embedding pass per burst of edits.
    • Any change here touches derived state (vector rows and chunk hashes). Per the repo's consistency model, the fix should stay lock-free and rely on later passes to converge.

    I stopped after triage and made no code changes.

  3. added
    cloud
    on Oct 20, 2026
  4. added a commit that references this issue on Oct 23, 2026
    0ce43a4
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

    bugcloudcost-review-2026-10

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions