-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 brew module package install & upgrade #9022
Speed up brew module package install & upgrade #9022
Conversation
…t_package` (Skip one brew info)
…nt_package(Skip 2 brew commands)
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.
Thanks for your contribution! I don't know much about brew, so I cannot comment on the other changes, but I have a tiny note for the changelog fragment :)
Co-authored-by: Felix Fontein <[email protected]>
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.
LGTM
@UnknownPlatypus thanks for your contribution! |
Thank you both for the quick review! Was a pleasure to contribute! Would you be open to a follow-up PR addressing the other optimisation ideas I left in the PR description? Cheers! |
There is no active module maintainer for this module, so there's nobody to say "no" :) We generally accept all PRs that look good enough and don't fail CI. |
Absolutely! Contributions are more than welcome! :-) |
Awesome, I'll submit new PR's then and will try to keep them scoped clearly to ease review! Thanks! |
SUMMARY
I noticed while working with the homebrew module that it was quite slow, even when doing noops so I instrumented the code a bit to understand why.
For the following task:
I got the following logs:
Lot's of redundant commands that are quite expensive because of
brew
.This PR addresses some quick wins, removing duplicated
_current_package_is_installed
calls in both example above.However, this could be improved further. Some ideas for other PRs if interest arise:
current_package_is_outdated
hook is always used with_current_package_is_installed
, requiring 2 brew call while onebrew info
returns both info._upgrade_current_package
is called in a loop, leading to a lot ofbrew info
/brew outdated
calls (N+1 issue) when the list of package is large. It would be much more efficient to fetch every packages installed first (brew list --formula -1
), every outdated packages (brew outdated --json=v2
) and then just check against these lists.ISSUE TYPE
COMPONENT NAME
homebrew
ADDITIONAL INFORMATION
The code I used to instrument the `Homebrew` class