Skip to content

File search through the file service: score each file once per sort - #350407

Draft
Federico Brancasi (federicobrancasi) wants to merge 1 commit into
mainfrom
fbrancasi/fs-file-search-score-once
Draft

Federico Brancasi (federicobrancasi) wants to merge 1 commit into
mainfrom
fbrancasi/fs-file-search-score-once

Conversation

@federicobrancasi

Copy link
Copy Markdown
Member

FileSystemFileSearchProvider searches file systems that have no native search, for the file tree of the Agents window and the agent host file system. It sorted all matches with compareItemsByFuzzyScore, which scores both items on every comparison, with a new accessor object each time.

This PR uses createItemsByFuzzyScoreComparator (added in #349718 for Go to File), which scores each item once per sort and keeps the same order. The accessor is created once.

No issue is associated; this came from profiling.

Measured on my machine

Node benchmark: the 21,608 paths of this repository, the provider's accessor, each prefix of six typed queries (70 queries), filtering with fuzzyContains and then the full sort, median of 5 runs:

Before After
All 70 queries 4.31 s 2.05 s

The sorted order was identical for every query.

How to test

Command Result
./scripts/test.sh --run src/vs/workbench/services/search/test/common/fileSystemFileSearchProvider.test.ts --run src/vs/base/test/common/fuzzyScorer.test.ts passed, 78 passing
node_modules/.bin/tsc --project ./src/tsconfig.json --noEmit --skipLibCheck no errors in the changed files (9 errors in src/vs/platform/agentHost/, from my local Copilot SDK package being older than the one on main)
node_modules/.bin/oxlint src/vs/workbench/services/search/common/fileSystemFileSearchProvider.ts passed

FileSystemFileSearchProvider sorted its matches with
compareItemsByFuzzyScore, scoring both items on every comparison. Use
createItemsByFuzzyScoreComparator, which scores each item once and
keeps the same order.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 15:52
Copilot stopped reviewing on behalf of Federico Brancasi (federicobrancasi) due to an error November 25, 2026 15:55

This branch has not been deployed

No deployments
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