-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
perf(package): only try to read files that exist #3904
Conversation
Have refactored the package module to improve performance. Before this change the module would try to open every single file that could contain some package information until it found a valid version. This resulted in a lot of unneeded disk IO. Have added a new fn, `read_file_from_pwd` that uses the current context to check if that file already exists and fast failing if it doesn't. From my local testing this speeds up the package module from taking ~1ms to ~50µs in an empty directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes themselves look good.
A few other files seem to have similar utils::read_file(context.current_dir.join("..."))
calls, so this should perhaps also cover those.
The only one I found from a quick check was the haskell module, which I have updated, but maybe I missed something. Edit scratch that just noticed can update the node module. |
@andytom There's also the nodejs module has ( |
Thanks for the review @davidkna |
Description
Have refactored the package module to improve performance. Before this
change the module would try to open every single file that could contain
some package information until it found a valid version. This resulted
in a lot of unneeded disk IO. Have added a new fn,
read_file_from_pwd
that uses the current context to check if that file already exists and
fast failing if it doesn't.
Motivation and Context
From my local testing this speeds up the package module from taking ~1ms to ~50µs in an empty directory.
Screenshots (if appropriate):
How Has This Been Tested?
Checklist: