Skip to content

perf(index): removal purge of a 320-tool server takes ~5.5 s (Spec 116 SC-004 budget 500 ms) #1617

Description

@Dumbris

Summary

Spec 116 SC-004 requires a removal whose index purge drops a 320-tool server to finish with p99 < 500 ms. It currently takes about 5.5 s, roughly 11 times the budget. The config commit holds configCommitMu for that whole time.

Measurement

internal/runtime/spec116_sc004_test.go (MCPPROXY_SC004_MEASURE=1, in-process, 25-server config, Apple M-series, PR #1612 branch):

Budget Measured
commit, no index work: p99 < 50 ms p99 20.0 ms (n=300)
removal with a 320-tool purge: p99 < 500 ms p50 5.56 s, p99 6.26 s (n=40)
retirement of one connected instance: < 100 ms p99 42 µs (Retire); removal commit p99 39.8 ms (n=40)

Cause

commitIndexPurge calls index.Manager.DeleteServerTools, which is BleveIndex.DeleteServerTools (internal/index/bleve.go). It runs one b.index.Delete(hit.ID) per tool, and each call is a separate bleve/bolt write transaction with its own fsync (about 17 ms each). This code predates Spec 116; PR #1612 does not touch internal/index.

A second issue in the same function: searchReq.Size = 1000 silently leaves the tools past 1000 in the index.

Suggested fix

Delete every hit in one index.NewBatch() / index.Batch(b), and page the search (or loop until no hits remain) so that servers with more than 1000 tools are fully purged. Re-run the SC-004 measurement afterwards and tick T098 in specs/116-config-commit-consistency/tasks.md.

Found while answering a review finding on #1612 (Spec 116 PR4, T098 / SC-004).

Activity

  1. added a commit that references this issue on Oct 16, 2026
    77fba60
  2. added a commit that references this issue on Oct 18, 2026
    f4b3c92
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