Speed up the update_stale function. #165
Merged
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.
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:
And after:
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!