Skip to content

Improve CodeMap parsing concurrency#590

Open
baron wants to merge 1 commit into
mainfrom
wt/codemap-parsing-concurrency
Open

Improve CodeMap parsing concurrency#590
baron wants to merge 1 commit into
mainfrom
wt/codemap-parsing-concurrency

Conversation

@baron

@baron baron commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • remove the global Tree-sitter execution lock that serialized independent CodeMap files
  • keep cache initialization synchronized while parser, tree, and query-cursor state remains operation-local
  • bound default CodeMap admission to the effective bulk permit capacity, preserving one foreground permit
  • add real production-permit mixed-language overlap/golden coverage and an N>1 cancellation regression

Performance

Five warmed production-path samples over 16 mixed Swift, TypeScript, Python, and Go artifacts:

Metric Before After
Median wall time 8.59 s 3.32 s
Throughput improvement - 2.59x
Median CPU time 9.10 s 9.24 s (+1.6%)
Observed parser concurrency 1 3
Process peak RSS 84.49 MB 89.15 MB (+5.5%)

The effective CodeMap limit is max(1, min(4, activeProcessorCount) - 1), matching the existing bulk permit cap and retaining foreground capacity.

Validation

  • CodeMapArtifactBuildCoordinatorTests: passed
  • WorkspaceCodemapGitCapabilityServiceTests: 17/17 passed in isolation
  • PersistentAgentModeMCPReadFileConnectionTests: 20/20 passed in isolation
  • PromptContextPreAssemblyServiceTests: 17/17 passed in isolation
  • strict SwiftFormat and SwiftLint: passed
  • RepoPrompt product build: passed
  • authoritative test list and ledger verification: passed, 3,439 tests
  • commit and push secret/guardrail preflights: passed

The full root-suite PR-ready run reported failures in the three suites above plus unrelated cross-suite state, but each reported suite passed independently afterward. The focused CodeMap suite also passed on the refreshed main base. No implementation scope was added for those unrelated cross-suite failures.

Review

Claude Fable 5 High reviewed the implementation before and after its initial findings were fixed, then reviewed it again after refreshing to current main. Final review found no must-fix or should-fix findings.

Notes

  • cancellation, currentness, persistence, and publication logic are unchanged
  • no parser pool or second worker pool was introduced
  • shared cached Query execution was verified against the pinned SwiftTreeSitter implementation: each execution owns a fresh cursor and no query mutators are used

Comment on lines 353 to +357
try Task.checkCancellation()
let outcome = try CodeMapSyntaxArtifactBuilder.build(
source: input.source,
language: input.language
language: input.language,
syntaxManager: syntaxManager

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The CodeMapArtifactBuilderClient initializer now requires a concrete SyntaxManager instead of the any CodeMapSyntaxQuerying protocol, which reduces testability and breaks dependency inversion.
Severity: LOW

Suggested Fix

Revert the syntaxManager parameter in the CodeMapArtifactBuilderClient initializer back to the protocol type any CodeMapSyntaxQuerying. This will restore the abstraction boundary, allowing mock implementations to be injected for testing and adhering to better API design principles.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location:
Sources/RepoPrompt/Features/CodeMap/CodeMapArtifactBuildCoordinator.swift#L353-L357

Potential issue: The initializer for `CodeMapArtifactBuilderClient` was updated to
require a concrete `SyntaxManager` instance for its `syntaxManager` parameter, instead
of the `any CodeMapSyntaxQuerying` protocol. This change breaks the abstraction
boundary, preventing the injection of mock objects for testing purposes. While existing
tests and production code are unaffected because they either use alternative
initializers or pass a real `SyntaxManager`, this design regression introduces technical
debt. It makes future testing more difficult by removing the ability to substitute mock
implementations that conform to the protocol, violating the dependency inversion
principle.

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant