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 the update_stale function. #165

Merged
merged 1 commit into from
Mar 28, 2020

Conversation

hworld
Copy link
Contributor

@hworld hworld commented Mar 28, 2020

More performance fun!

I noticed that the extension output was pausing during "Checking for stale beam files." After digging in, I realized that the code was using a private API function of Mix (Mix.Utils.extract_stale) which was always returning every single file in the project had changed on every save.

I tried to track down what Mix was doing, and basically pulled in a modified flow from that project, only supporting what we need. I still don't know why it was failing to do the proper checks, but the code in this PR is only fetching the files that have changed since the last analysis.

I decided to wrap it in a timing call so we can keep an eye on it, as well as logging how many files it found that "changed." I also added a test that works correctly to make sure that this functions properly.

As for performance, the before on a sample project of mine:

Found 1325 changed files in 3799 milliseconds
Found 1325 changed files in 4221 milliseconds
Found 1325 changed files in 3970 milliseconds

And after:

Found 1 changed files in 22 milliseconds
Found 1 changed files in 32 milliseconds
Found 1 changed files in 30 milliseconds

This is code that is at the start of the flow before it can run the analysis. With this fix, the analysis after saving in my project I get error reporting within 2s, which feels really good!

Copy link
Member

@axelson axelson left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for removing one of the private api usages 🎉

@axelson axelson merged commit 48a032b into elixir-lsp:master Mar 28, 2020
axelson added a commit that referenced this pull request Mar 28, 2020
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.

2 participants