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

Performance improvements to fuzzysearch #1359

Merged

Conversation

Wouter01
Copy link
Member

Description

While working on the filesystem refactoring, I noticed the fuzzysearch implementation had a few things making it more expensive than it should be. For example, the score function was calculated inside the sort function. This will recompute the score function needlessly as values are compared multiple times.

I made some simple adjustments which fix this issue. There were also some synchronous calls to the file system, so I made the code asynchronous which speeds it up even more.

As a bonus, the fuzzy search will now also work better with tabs and newlines, instead of only spaces.

Here are some test results for a large project, where I search for "t", "te", "tes" and "test" respectively.

Before

2.480142417 seconds
2.406085875 seconds
6.783014 seconds
6.755943334 seconds

After

0.465098708 seconds
0.444613625 seconds
0.431536375 seconds
0.391247541 seconds

Note that these results are not ordered as the current implementation won't cancel a previous search when a new one is initiated. This is another issue and is out of scope of this PR (it'll probably be fixed in the file system PR)

Related Issues

None

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Copy link
Collaborator

@thecoolwinter thecoolwinter left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@matthijseikelenboom matthijseikelenboom left a comment

Choose a reason for hiding this comment

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

LGTM

@matthijseikelenboom matthijseikelenboom merged commit 2326284 into CodeEditApp:main Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants