Add short-lived cache for documents and filter by language in linkifier.#2211
Merged
vijayupadya merged 1 commit intomicrosoft:mainfrom Jan 21, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes the inline code symbol linkifier to address severe performance issues during LLM response streaming. The linkifier was performing O(N×M) file reads (N = backticked symbols, M = reference files) by re-reading every file for each symbol. The PR implements two key optimizations:
- Language gating: Skip files entirely when their language isn't supported by tree-sitter in
symbolMatchesOnlymode - Document caching: Add per-resolver document cache to ensure each file is read at most once per response
| @@ -190,6 +214,7 @@ async function getSymbolsInRange(parserService: IParserService, doc: SimpleTextD | |||
| export class ReferencesSymbolResolver { | |||
| /** Symbols which we have already tried to resolve */ | |||
| private readonly cache = new Map<string, Promise<vscode.Location[] | undefined>>(); | |||
There was a problem hiding this comment.
[nitpick] Consider adding a JSDoc comment to document the purpose of the documentCache field. For example:
/** Cache of documents read during symbol resolution to avoid redundant file I/O within a single response. */
private readonly documentCache = new Map<string, Promise<SimpleTextDocument | undefined>>();This would help future maintainers understand that the cache is per-resolver instance (and thus per-response) and is meant to avoid reading the same file multiple times during linkification of a single response.
Suggested change
| private readonly cache = new Map<string, Promise<vscode.Location[] | undefined>>(); | |
| private readonly cache = new Map<string, Promise<vscode.Location[] | undefined>>(); | |
| /** | |
| * Cache of documents read during symbol resolution to avoid redundant file I/O within a single response. | |
| * This cache is per-resolver instance (and thus per-response) and is meant to avoid reading the same file | |
| * multiple times during linkification of a single response. | |
| */ |
Member
Author
|
@mjbvz any progress on reviewing this one? |
Contributor
|
s |
vijayupadya
approved these changes
Jan 21, 2026
dmitrivMS
approved these changes
Jan 21, 2026
eleanorjboyd
pushed a commit
to eleanorjboyd/vscode-copilot-chat
that referenced
this pull request
Jan 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Optimize inline code symbol linkifier to avoid redundant file I/O
The inline code linkifier (InlineCodeSymbolLinkifier) was causing severe performance issues during LLM response streaming. For each backticked symbol (e.g., TextDocument), it would re-read every reference file from disk, resulting in O(N×M) file reads where N = symbol count and M = reference count.
Changes:
Language gating: Skip files entirely when tree-sitter doesn't support their language (.log, .md, .json, etc.) in symbolMatchesOnly mode—zero I/O for unsupported files.
Document cache: Add a per-resolver documentCache so each file is read at most once per response, reducing file reads from O(N×M) to O(M).
Impact: Responses with many backticked symbols and large context files (especially non-code files like logs) should no longer hang the UI. Should help with microsoft/vscode#275716