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
Optimize brew update
by batching git cat-file
operations
#13244
Conversation
5499353
to
cdc4d78
Compare
| Homebrew Branch | Command | Commits Rewound | Time Elapsed | Updated Formulae | | --- | --- | --- | --- | --- | | `master` | `git -C "$(brew --repo homebrew/core)" reset --hard aa1b3d5; time sh -c "brew update &> output-2k.txt"` | 2,000 | 35.6s | 666 | | `master` | `git -C "$(brew --repo homebrew/core)" reset --hard 11e6919; time sh -c "brew update &> output-20k.txt"` | 20,000 | 129.8s | 2411 | | Homebrew#13234 | `git -C "$(brew --repo homebrew/core)" reset --hard aa1b3d5; time sh -c "brew update &> output-2k-unfiltered.txt"` | 2,000 | 6.6s | 819 | | Homebrew#13234 | `git -C "$(brew --repo homebrew/core)" reset --hard 11e6919; time sh -c "brew update &> output-20k-unfiltered.txt"` | 20,000 | 10.4s | 3532 | | _this one_ | `git -C "$(brew --repo homebrew/core)" reset --hard aa1b3d5; time sh -c "brew update &> output-2k-optimized.txt"` | 2,000 | 7.1s | 657† | | _this one_ | `git -C "$(brew --repo homebrew/core)" reset --hard 11e6919; time sh -c "brew update &> output-20k-optimized.txt"` | 20,000 | 17.6s | 2411 | † I haven't determined why there's a discrepancy between "Updated Formulae" on row 5 and row 1. Fixes Homebrew#13224
cdc4d78
to
362adb6
Compare
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.
Appreciate the work here but would love to avoid having a new class just for this lookback and instead look at improving FormulaVersions
to be more performant instead.
@MikeMcQuaid, would you be receptive to a PR that kept |
@boblail Potentially: depends on how much the complexity increases. I'm not really convinced that the solution here is in |
|
@MikeMcQuaid, what do you think of this refactor? It
|
contents = next_entry ? s.scan_until(/^(?=#{Regexp.escape(snip)}|#{next_entry} missing)/) : s.rest | ||
[entry, contents] | ||
else | ||
raise "that didn't work" |
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.
- Better error message
I don't love it, I'm afraid. What's the performance benefit here for the typical and pathological cases? Would love to see what the same answers are for #13243 (comment) This feels like it makes the code significantly more complex and hard to follow. That's perhaps worth it but I'd need numbers to decide. |
@MikeMcQuaid, would you consider running (At Square, we nudge engineers to do this monthly and we regularly see outliers who haven't done it in several months.) If so, this branch makes
|
@boblail Yeh, that's a decent speedup, thanks. I'm going to want to iterate a lot on the implementation here so I'd rather if we can land something like #13243 (comment) to simplify the need for this instead. |
I think #13299 may remove the need for this but interested in thoughts. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Passing on this given recent |
This approach is almost as optimal as omitting this filtering altogether.
It relies on
git cat-file --batch
, which can receive a list of blobs to look up on standard input.master
git -C "$(brew --repo homebrew/core)" reset --hard aa1b3d5df78; time sh -c "brew update &> output-2k.txt"
master
git -C "$(brew --repo homebrew/core)" reset --hard 11e6919661c; time sh -c "brew update &> output-20k.txt"
git -C "$(brew --repo homebrew/core)" reset --hard aa1b3d5df78; time sh -c "brew update &> output-2k-unfiltered.txt"
git -C "$(brew --repo homebrew/core)" reset --hard 11e6919661c; time sh -c "brew update &> output-20k-unfiltered.txt"
git -C "$(brew --repo homebrew/core)" reset --hard aa1b3d5df78; time sh -c "brew update &> output-2k-optimized.txt"
git -C "$(brew --repo homebrew/core)" reset --hard 11e6919661c; time sh -c "brew update &> output-20k-optimized.txt"
Fixes #13224
Alternatives
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?