Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

speed up & respect ignores in finding workspace files for file @-mentions #3433

Merged
merged 2 commits into from
Mar 18, 2024

Conversation

sqs
Copy link
Member

@sqs sqs commented Mar 16, 2024

  1. Finding the list of files now respects the files.exclude,
    search.exclude, and gitignore/ignore files. This makes it much faster
    (~1200ms -> 100ms on sourcegraph/sourcegraph on my machine) and eliminates
    irrelevant files (such as tons of bazel-bin/ and *.js files).
  2. Removes the cancellation on throttledFindFiles. This actually made it
    slower because each time throttledFindFiles.cancel() was called, it would
    invalidate the cached result, which means the next call would invoke the
    expensive find-files operation even if it had been less than 10000ms since
    the previous successful call. We do not need cancellation for this
    operation because each call uses the same arguments, so earlier calls are
    not wasted and just mean the result will be returned slightly sooner.

Note: the e2e tests have 1 change because the .gitignore in the vscode/test/fixtures/workspace dir is now respected, so there is one less item in the dropdown. This is an enhancement.

Before

files-before

After

after-file

Test plan

CI

@sqs sqs requested a review from a team March 16, 2024 18:15
@sqs sqs changed the title speed up finding workspace files for file @-mentions speed up & respect ignores in finding workspace files for file @-mentions Mar 16, 2024
@sqs sqs force-pushed the sqs/faster-find-file branch 4 times, most recently from abe0eec to dec6cbb Compare March 17, 2024 06:46
sqs added 2 commits March 17, 2024 00:15
1. Finding the list of files now respects the `files.exclude`, `search.exclude`, and gitignore/ignore files. This makes it much faster (~1200ms -> 100ms on sourcegraph/sourcegraph on my machine) and eliminates irrelevant files (such as tons of `bazel-bin/` and `*.js` files).
2. Removes the cancellation on `throttledFindFiles`. This actually made it slower because each time `throttledFindFiles.cancel()` was called, it would invalidate the cached result, which means the next call would invoke the expensive find-files operation even if it had been less than 10000ms since the previous successful call. We do not need cancellation for this operation because each call uses the same arguments, so earlier calls are not wasted and just mean the result will be returned slightly sooner.

Note: the e2e tests change because the `.gitignore` in the vscode/test/fixtures/workspace dir is now respected, so there is one less item in the dropdown. This is an enhancement.
@toolmantim
Copy link
Contributor

~1200ms -> 100ms — wowsers!

Copy link
Contributor

@philipp-spiess philipp-spiess left a comment

Choose a reason for hiding this comment

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

Awesome stuff. I hope we can get the better file api to clean up some of this.

Also this doesn't pull in nested gitignore files yet making it less useful on repos with more than one project but I don't know if it's worth it preemtively looking at every ignore file in the workspace and building a giant ignore list just to support that. 😐

@sqs sqs merged commit be985fb into main Mar 18, 2024
15 of 16 checks passed
@sqs sqs deleted the sqs/faster-find-file branch March 18, 2024 15:16
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.

None yet

3 participants