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

Don’t prefetch greedy outdated casks #1309

Merged
merged 3 commits into from
Feb 22, 2024

Conversation

jneubrand
Copy link
Contributor

@jneubrand jneubrand commented Feb 20, 2024

In some instances, calling .outdated?(greedy: true) causes additional network requests. (casks using version :latest and sha256 :no_check seem to trigger this)

Currently, this is done for all installed packages every time brew bundle wants to update any cask greedily.

This pull request changes bundle's behavior to only check whether one cask is outdated at a time (for greedy updates).

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

This pull request changes bundle's behavior to only check whether one cask is outdated at a time (for greedy updates).

Can you explain why this is better?

What network requests does this avoid?

lib/bundle/cask_dumper.rb Outdated Show resolved Hide resolved
lib/bundle/cask_dumper.rb Outdated Show resolved Hide resolved
lib/bundle/cask_dumper.rb Outdated Show resolved Hide resolved
@jneubrand
Copy link
Contributor Author

Can you explain why this is better?

What network requests does this avoid?

For all of the following casks…

grep -IirE '^ +version :latest' -A 1 /usr/local/Homebrew/Library/Taps | grep 'sha256 :no_check' -B 1

(a few dozen nightlies from homebrew-cask-versions, but also many homebrew-fonts)

…the entire current file has to be downloaded every time to check whether the contents that would be installed are equivalent.


Thanks for the notes, I don't deal with ruby often 😅

@MikeMcQuaid
Copy link
Member

…the entire current file has to be downloaded every time to check whether the contents that would be installed are equivalent.

Yeh, this is expected when using --greedy. What's not clear though is how your PR makes this different?

Does this mean that brew bundle will behave the same if your Brewfile lists all installed casks but if it only has e.g. one cask it'll only download that one whereas before it would download them all?

@jneubrand
Copy link
Contributor Author

jneubrand commented Feb 20, 2024

brew bundle will behave the same if your Brewfile lists all installed casks but if it only has e.g. one cask it'll only download that one whereas before it would download them all?

Well, it won’t download a cask without the greedy: true flag anymore. If you only set that flag on some casks, or if you don’t list that kind of cask at all, this PR speeds brew bundle. (edit: so yes, if you have a single line in your Brewfile with greedy: true, only that one will be downloaded)

@MikeMcQuaid
Copy link
Member

don’t list that kind of cask at all, this PR speeds brew bundle

If you don't use greedy in your cask file at all: it wasn't being used already.

So is it now that greedy will only check specific casks greedily rather than any cask being greedy triggering checking all casks greedily?

@jneubrand
Copy link
Contributor Author

don’t list that kind of cask at all, this PR speeds brew bundle

If you don't use greedy in your cask file at all: it wasn't being used already.

So is it now that greedy will only check specific casks greedily rather than any cask being greedy triggering checking all casks greedily?

Yup!

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Thanks so much for your first contribution! Without people like you submitting PRs we couldn't run this project. You rock, @jneubrand!

@MikeMcQuaid MikeMcQuaid merged commit 5da3147 into Homebrew:master Feb 22, 2024
4 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants