Skip to content

perf(mcp): bound unqualified code_references batch waits - #1713

Merged
alex09x merged 6 commits into
mainfrom
perf/1594-bound-unqualified-reference-batch
Oct 28, 2026
Merged

alex09x merged 6 commits into
mainfrom
perf/1594-bound-unqualified-reference-batch

Conversation

@alex09x

@alex09x alex09x commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Problem

Issue #1594 describes Rust code_references lookups for common unqualified names taking up to about 20 seconds in multi-target discovery. A batch of several symbols also needs to preserve time for later entries and return useful partial results when one reference scan exhausts its share.

Change

  • Give each unqualified code_references batch symbol a default 2 second share when no path hint or explicit budget is supplied.
  • Pass the share into execute_tool without an outer timeout that would abort candidate resolution and discard the structured partial result. The batch stops starting later symbols when its shared budget is exhausted.
  • Do not apply the default unqualified cap when the caller supplies a path/file hint; explicit budgets remain in control.
  • Make the multi-target reference scan use the remaining budget_ms from the start of handle_references, cap it at the existing 8 second maximum, and return an explicit partial-results note when the scan reaches its deadline.

Reproduce and verify

Unit regressions verify that an unqualified name receives the 2 second budget, a path-scoped name retains the shared budget, an explicit budget overrides the default cap, and a partial result returned just after the 2 second share survives the batch wrapper. The existing multi-candidate test verifies that execute_tool returns candidate/partial guidance when its own shared budget expires. Reference-scan tests verify that shorter budgets are honored, long budgets retain the 8 second cap, and an expired deadline returns partial guidance without issuing an LSP query.

Measurements

No performance claim. The batch regression waits 2.1 seconds to prove a returned partial result is not discarded at the former outer 2 second timeout.

Checks

Revision 3c369d284cd72a7b42102d8820469ac49350bcc5, Linux build node:

  • cargo fmt --all -- --check: exit 0.
  • cargo clippy -p prod-code-mcp --all-targets: exit 0 with existing warnings (125 warnings in the test build); this is not a strict-clean lint claim.
  • cargo test -p prod-code-mcp --lib unqualified_reference_batch_ -- --nocapture: 2 passed, 0 failed.
  • cargo test -p prod-code-mcp --lib multi_target_deadline -- --nocapture: 2 passed, 0 failed.
  • cargo test -p prod-code-mcp --lib multi_candidate_shared_budget_returns_partial_result_when_expired -- --nocapture: 1 passed, 0 failed.
  • prod-code impact --base origin/main --depth 1 --json: exit 0; it selected the direct batch/reference tests and reported incomplete caller coverage at depth 1. No broad suite was run.

The current head also integrates #1715. Its merge commit adds the definition-body worktree fix, tests and changelog only; batch/reference sources and tests are unchanged from f2c94f47.

Closes #1594

@alex09x alex09x added perf Latency, throughput, memory gateway Server daemon mcp MCP tools for agents labels Oct 28, 2026
@alex09x
alex09x marked this pull request as ready for review October 28, 2026 08:50
@alex09x

alex09x commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Independent read-only P0–P3 review of 103b521: APPROVE, no findings. The batch/reference deadlines and partial-result regressions passed on the current base.

@alex09x

alex09x commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Independent read-only P0–P3 re-review of 3c369d2: APPROVE, no findings. The current-base merge contains no changes to the batch/reference implementation or tests; all focused checks are recorded in the PR.

@alex09x
alex09x merged commit e3e8668 into main Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Server daemon mcp MCP tools for agents perf Latency, throughput, memory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

code_references: unqualified Rust lookup takes 20 seconds before returning a timeout

1 participant