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
Improve performance of brew readall
#16007
Conversation
be01e82
to
2243c09
Compare
If we're going to move the |
We ideally want to However we could just get rid of |
In theory |
Sorry, where would we be removing the I still think it's a bit of a weird thing to add to |
This makes sense to me. I was also leaning towards "let's just have a single check that loads all formulae". From that perspective, I agree
Sounds like it.
Core, not here. |
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.
Performance changes look good. Maybe split out the to_h
ones into another PR?
cache[:valid_formulae][file] = if readall_formula.on_system_blocks_exist? | ||
[bottle_tag, *cache[:valid_formulae][file]] | ||
else | ||
true | ||
end |
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.
cache[:valid_formulae][file] = if readall_formula.on_system_blocks_exist? | |
[bottle_tag, *cache[:valid_formulae][file]] | |
else | |
true | |
end | |
unless readall_formula.on_system_blocks_exist? | |
cache[:valid_formulae][file] = true | |
end |
I don't think we really need to track the case where a formula uses on system blocks. We only run this method once per os/arch combination anyway.
The main thing we're trying to do here is avoid reading formula without on system blocks multiple times (since they shouldn't change), right?
[2] brew(main)> CoreTap.instance.formula_files.count do |file|
[2] brew(main)* Formulary.factory(file).on_system_blocks_exist?
[2] brew(main)* end
=> 880
[3] brew(main)> CoreTap.instance.formula_files.count
=> 6781
Isn't it possible to use the manual os and arch functions in formula definitions though like OS.mac?
? Or maybe that's only limited to certain stanzas like install
and test
that aren't relevant for brew readall
. To be fair this command was update recently to test against different os/arch combinations but it does change the behavior, right?
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.
We don't actually allow on_system
blocks inside install
and test
. We do however in caveats
, which is read by to_hash
.
Idea being it would catch something like:
def caveats
on_linux do
oopsie
end
"test"
end
Basically the hope is that brew generate-formula-api
should never fail if brew readall
passes, or at least 99.9% of the time.
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.
Sounds good. Do you think this sort of optimization would be useful for the cask repo as well at some point?
I've changed my mind. I think adding the |
brew readall
and add additional checksbrew readall
2243c09
to
e4623cc
Compare
Split this into:
|
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.
Looks good, thanks again @Bo98!
to_hash
check to ensure the method used for API generation (andbrew info
etc) doesn't error. This increases that 30s back up to 47s (after some optimisations) but does mean we could remove the 90 secondbrew generate-formula-api
call in tap_syntax checks as the other elements of that command shouldn't be affected by formula changes.These changes affect formulae only. I have not touched casks.