Skip to content

PullStore: per-URI forget so closing one document doesn't clear every memo #52

Open

Description

@MelbourneDeveloper

Problem

PullStore::clear() (crates/lspkit-server/src/pull.rs:255, released in 0.5.0) is the only way to release diagnostic memos, and it drops the whole database.

A consumer that closes a single document has two bad choices:

  • call clear() and throw away every other open document's memos (all of them re-pull cold), or
  • keep the closed document's memos and inputs alive until the next solution switch (memory grows with every file opened in a session).

SharpLsp currently calls clear() on every didClose, so closing one tab invalidates diagnostics for every open tab.

Ask

A per-document eviction, e.g. PullStore::forget(&self, uri: &Uri) -> Result<(), PullError>, that:

  1. removes the URI's input and the memos derived only from it,
  2. leaves every other URI's memos warm (a following pull of another URI hits the cache),
  3. makes a later pull of the forgotten URI recompute from scratch.

If Salsa can't delete inputs, an acceptable shape is a tombstone input (set the URI's text to an empty sentinel + drop it from the store's key map) plus a heap-leak test like outbound_heap_leak.rs proving open/forget cycles don't grow allocated bytes.

Acceptance tests

  • open A, B → pull both → forget A → pull B is a cache hit, pull A recomputes
  • 1000 open/forget cycles of distinct URIs → heap bytes bounded (allocated == freed within tolerance)
  • forget of an unknown URI is Ok(()) (idempotent)

Activity

  1. MelbourneDeveloper commented on Nov 17, 2026

    @MelbourneDeveloper
    CollaboratorAuthor

    Landing in v0.6.0 via PR #51 (not after it): d2a22c4, 029e583 (Windows agent), 950c04c, 1f05b40. PullStore::forget(uri) keeps every other document warm: same result_id and no recompute. The forgotten URI recomputes, and a close never runs the compiler. A close frees its report at once when idle, a close during an in-flight pull is freed as that pull finishes, and repeated closes queue one entry. Tests: tests/pull_forget.rs and tests/pull_forget_heap.rs (1000 distinct open/forget cycles free exactly what they allocate; closing 32 idle 64 KiB documents frees every byte). Mutants of each fix line are killed, including the two SharpLsp1 found. The reference server now calls forget on didClose. Evidence: docs/plans/issue-fix-evidence-21-26-48-49.md.

  2. MelbourneDeveloper commented on Nov 17, 2026

    @MelbourneDeveloper
    CollaboratorAuthor

    ✅ Released in v0.6.0 and verified against the published crates

    Release: https://github.com/Nimblesite/lspkit/releases/tag/v0.6.0 (run 44186953235, tag at 8e39446). It contains lspkit, lspkit-server, lsp-profiler and lsp-profiler-dotnet 0.6.0 on crates.io, plus @nimblesite/lsp-profiler-ui@0.6.0 on npm (with provenance), the .NET engine for 6 runtime ids, the consumer kit, an SBOM, and SHA256SUMS signed with cosign.

    Method: a worktree at v0.6.0, with crates/lspkit/src and crates/lspkit-server/src replaced by the sources unpacked from the crates.io 0.6.0 downloads. The published source is byte-identical to the tag. Results against the released code:

    #21 sidecar_disconnect_session: test result: ok. 2 passed; 0 failed
    #26 cancel_during_a_scan: test result: ok. 1 passed; 0 failed
    #48 outbound: test result: ok. 3 passed; 0 failed
    #48 outbound_heap_leak: test result: ok. 1 passed; 0 failed
    #48 sidecar_correlator: test result: ok. 12 passed; 0 failed
    #49 uri: test result: ok. 17 passed; 0 failed
    #49 uri_authority: test result: ok. 1 passed; 0 failed
    #49 style_tests: test result: ok. 5 passed; 0 failed
    #52 pull_forget: test result: ok. 5 passed; 0 failed
    #52 pull_forget_heap: test result: ok. 1 passed; 0 failed
    #53 jsonrpc: test result: ok. 21 passed; 0 failed
    #53 jsonrpc_frame_heap: test result: ok. 1 passed; 0 failed
    

    Breaking: the lspkit-server/mcp feature is removed. lsp_profiler::session::rfc3339_now is now lsp_profiler::clock::rfc3339_now. A lone %, or an encoded separator, in a file URI is now an error. Consumers on didClose should call PullStore::forget(uri) instead of clear().

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions